Skip to content

Commit

Permalink
fix keys after changes for children's camera
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyakurdyukov authored Dec 16, 2023
1 parent 04d09ef commit 2d97d4d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions fpdoom/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void entry_main(char *image_addr, uint32_t image_size, uint32_t bss_size) {
sys_data.charge = -1;
sys_data.spi_mode = 3;
sys_data.bl_gpio = 0xff;
sys_data.keycols = 5;

while (argc) {
if (argc >= 2 && !strcmp(argv[0], "--bright")) {
Expand Down Expand Up @@ -201,6 +202,10 @@ void entry_main(char *image_addr, uint32_t image_size, uint32_t bss_size) {
} else if (argc >= 2 && !strcmp(argv[0], "--charge")) {
sys_data.charge = atoi(argv[1]);
argc -= 2; argv += 2;
} else if (argc >= 2 && !strcmp(argv[0], "--keycols")) {
unsigned a = atoi(argv[1]);
if (a <= 8) sys_data.keycols = a;
argc -= 2; argv += 2;
} else if (argc >= 2 && !strcmp(argv[0], "--keymap")) {
FILE *f = fopen(argv[1], "rb");
if (f) {
Expand All @@ -209,6 +214,7 @@ void entry_main(char *image_addr, uint32_t image_size, uint32_t bss_size) {
memset(sys_data.keytrn, -1, 64 * 2);
fread(sys_data.keytrn, 1, 64 * 2, f);
fclose(f);
sys_data.keycols = 8;
}
argc -= 2; argv += 2;
} else if (!strcmp(argv[0], "--")) {
Expand Down
2 changes: 1 addition & 1 deletion fpdoom/syscode.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ static void keypad_init(void) {
#if 0 // Usually col < 5 for SC6531DA.
int ncol = _chip != 1 ? 5 : 8;
#else // But the Children's Camera has UP at i=6, j=3.
int ncol = 8;
int ncol = sys_data.keycols;
#endif

for (i = 0; i < ncol; i++)
Expand Down
3 changes: 2 additions & 1 deletion fpdoom/syscode.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ extern struct sys_data {
struct sys_display { uint16_t w1, h1, w2, h2; } display;
int brightness;
uint16_t keytrn[2][64];
uint8_t keycols;
uint8_t scaler;
/* key << 4 | screen */
/* rotate = key << 4 | screen */
uint8_t rotate, lcd_cs;
uint8_t spi_mode;
int8_t charge;
Expand Down
2 changes: 1 addition & 1 deletion fpdoom/syscomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ int sys_getkeymap(uint8_t *dest) {
{ "\005\004\007\006987654321" },
{ "\006\007\005\004741852963" } };
int nrow = _chip != 1 ? 8 : 5;
int ncol = _chip != 1 ? 8 : 8;
int ncol = _chip != 1 ? sys_data.keycols : 8;
int flags = 0;

memset(dest, 0, 64);
Expand Down

0 comments on commit 2d97d4d

Please sign in to comment.