Add and wire up platform definition

This commit is contained in:
Puck Meerburg
2026-02-06 17:46:50 +00:00
parent 9d33f21da6
commit 88126c31b7
5 changed files with 99 additions and 27 deletions

View File

@@ -4,39 +4,14 @@
#include "CH58x_sys.h"
#include "CH58xBLE_LIB.h"
#include "led.h"
#include "platform.h"
uint32_t pa_mask;
uint32_t pb_mask;
#define A(v) v
#define B(v) (v | 0x80)
uint8_t pins[23] = {
A(15),
B(18),
B(0),
B(7),
A(12),
A(10),
A(11),
B(9),
B(8),
B(15),
B(14),
B(13),
B(12),
B(5),
A(4),
B(3),
B(4),
B(2),
B(1),
#ifdef IS_MICROUSB
B(23),
#else
B(6),
#endif
B(21),
B(20),
B(19),
LED_PINS
};
// Set up the pa_mask and pb_mask values.
@@ -98,12 +73,14 @@ void display_make_buf(uint16_t *fb, struct row_buf *b, int i) {
uint16_t col1 = fb[i * 2];
uint16_t col2 = fb[i * 2 + 1];
#if NEEDS_SWAP
// On the first column, the lower two pins are swapped. Fix this in software.
if (i == 0) {
uint16_t bit = col1 & 1;
col1 = (col1 & 0xFFFE) | (col2 & 1);
col2 = (col2 & 0xFFFE) | bit;
}
#endif
// The LEDs are written in a zig-zag pattern.
uint32_t merged = 0;

9
src/platform.h Normal file
View File

@@ -0,0 +1,9 @@
#if defined(PLATFORM_BADGEMAGIC)
#include "platforms/badgemagic.h"
#elif defined(PLATFORM_LS32_USBC)
#include "platforms/ls32-usbc.h"
#elif defined(PLATFORM_LS32_MICROUSB)
#include "platforms/ls32-microusb.h"
#else
#error "unknown platform define"
#endif

View File

@@ -0,0 +1,28 @@
#define BUTTON_COUNT 4
#define NEEDS_SWAP 0
#define HAS_MIC 1
#define LED_PINS \
A(15), \
B(18), \
B(0), \
B(7), \
A(12), \
A(10), \
A(11), \
B(9), \
B(8), \
B(17), \
B(16), \
B(13), \
B(12), \
B(5), \
A(4), \
B(3), \
B(4), \
B(2), \
B(1), \
B(6), \
B(21), \
B(20), \
B(19),

View File

@@ -0,0 +1,29 @@
#define BUTTON_COUNT 2
#define NEEDS_SWAP 1
#define HAS_MIC 0
#define LED_PINS \
A(15), \
B(18), \
B(0), \
B(7), \
A(12), \
A(10), \
A(11), \
B(9), \
B(8), \
B(15), \
B(14), \
B(13), \
B(12), \
B(5), \
A(4), \
B(3), \
B(4), \
B(2), \
B(1), \
B(23), \
B(21), \
B(20), \
B(19),

29
src/platforms/ls32-usbc.h Normal file
View File

@@ -0,0 +1,29 @@
#define BUTTON_COUNT 2
#define NEEDS_SWAP 1
#define HAS_MIC 0
#define LED_PINS \
A(15), \
B(18), \
B(0), \
B(7), \
A(12), \
A(10), \
A(11), \
B(9), \
B(8), \
B(15), \
B(14), \
B(13), \
B(12), \
B(5), \
A(4), \
B(3), \
B(4), \
B(2), \
B(1), \
B(6), \
B(21), \
B(20), \
B(19),