diff -r 5b1e0b384d31 -r 86f099bda525 src/main.cpp --- a/src/main.cpp Sun Aug 30 22:53:15 2020 +0200 +++ b/src/main.cpp Thu Oct 15 01:11:03 2020 +0200 @@ -15,54 +15,17 @@ #include "QEI.h" #include "Keypad.h" -/******************************************************/ -/* L432KC */ -/******************************************************/ -#if (defined STM32L432xx) -// display -#define DSP_MOSI PA_7 //A6 -#define DSP_MISO PA_6 //A5 -#define DSP_SCLK PA_5 //A4 -#define DSP_CS PB_0 //D3 -#define DSP_RST PB_5 //D11 -#define DSP_DC PB_4 //D12 - -// UART for RX (CPU->DP) and TX (DP->CPU) combined -#define HP_TX PA_9 // serial1 TX -#define HP_RX PA_10 // serial1 RX - -// RST pin (handle this by hand) -#define HP_RST PA_0 - -// misc -#define DBGPIN NC - -// encoder -#define KP_ENC1 PA_8 -#define KP_ENC2 PA_11 - -// keypad -#define KP_R0 PA_1 -#define KP_R1 PA_3 -#define KP_R2 PA_4 -#define KP_R3 PA_12 - -#define KP_C0 D4 -#define KP_C1 D5 -#define KP_C2 D6 -#define KP_C3 D7 -#define KP_C4 D8 /******************************************************/ /* F446RE */ /******************************************************/ -#elif defined STM32F446xx +#if defined STM32F446xx // UART // USBTX PA_2 // USBRX PA_3 // display #define DSP_MOSI PB_15 // blue -#define DSP_MISO NC +#define DSP_MISO PB_14 // NC #define DSP_SCLK PB_13 // yellow #define DSP_CS PB_12 // green #define DSP_RST PB_5 // green @@ -95,8 +58,41 @@ // misc #define DBGPIN PC_6 +#elif defined STM32F303xE // HP34970 replacement PCB + +#define DSP_MOSI PA_7 +#define DSP_MISO PA_6 // NC +#define DSP_SCLK PA_5 +#define DSP_CS PA_2 +#define DSP_RST PA_3 +#define DSP_DC PA_4 + +// UART for RX (CPU->DP) +#define HP_RX PC_5 +#define HP_TX PC_4 + +// RST pin (handle this by hand) +#define HP_RST PA_15 + +// encoder +#define KP_ENC1 PA_0 +#define KP_ENC2 PA_1 + +// keypad +#define KP_R0 PB_5 +#define KP_R1 PB_6 +#define KP_R2 PB_7 +#define KP_R3 PB_8 + +#define KP_C0 PC_2 +#define KP_C1 PC_1 +#define KP_C2 PC_0 +#define KP_C3 PB_4 +#define KP_C4 PB_0 + #endif + #ifdef HAVE_PC Serial pc(USBTX, USBRX); #endif @@ -164,7 +160,7 @@ Keypad *kpad; uint8_t curchar; -uint8_t cmd; +//uint8_t curcmd; uint8_t nchars; char buffer[MAX_BUFF+1]; @@ -245,14 +241,13 @@ { // flag, zone, x0, y0, reverse, msg, icon // right-side icons area - { 0x00, 246, 0, false, NULL, icon_alarm}, // F1.0 + { 0x00, 246, 0, false, NULL, icon_alarm}, // F1.0 { 0x01, 246, 11, false, NULL, icon_curve}, // F1.1 // F1.2 == Channel frame { 0x03, 197, 27, false, "Channel"}, // F1.3 // F1.7 == Alarm frame - { 0x34, 0, 28+8, false, "MON"}, // F4.4 { 0x33, 0, 28+16, false, "VIEW"}, // F4.3 { 0x35, 0, 28, true, "SCAN"}, // F4.5 @@ -402,7 +397,7 @@ dsp->foreground(0xF); dsp->cls(); - cmd = 0xFF; + //curcmd = 0xFF; curchar = 0; nchars = 0; @@ -439,7 +434,8 @@ void end_splashscreen(void) { - printf("End of splash screen CB\r\n"); + // print is forbidden here because we are in an ISR context here + //printf("End of splash screen CB\r\n"); splashscreen = false; } @@ -490,16 +486,20 @@ } */ pulse(0, false); - Thread::wait(30); + + ThisThread::sleep_for(30); } } void show(uint8_t cmd, const char *intxt, uint8_t nchar=0) { - uint8_t i, len; + uint8_t i; + // uint8_t len; uint16_t bgcolor, fgcolor; char *oldv; - char *txt, *txtp; + // char *txt; + char *txtp; + static char txt[256]; if (cmd == 0xFF) // cls @@ -508,13 +508,13 @@ } else { - txt = (char *)malloc(strlen(intxt)+1); + //txt = (char *)malloc(strlen(intxt)+1); strcpy(txt, intxt); txtp = txt; pulse(1, true); - len = MAX_BUFF; + // len = MAX_BUFF; for (i=0; ilocate(table[i].x0, table[i].y0); - if (table[i].fmt & 0x01 ) // ASCII text + if (table[i].fmt & 0x01) // ASCII text { if (strncmp(oldv, txt, table[i].maxsize) != 0) { if (table[i].width > 0) dsp->fillrect(table[i].x0, - table[i].y0, - table[i].x0 + table[i].width, - table[i].y0 + table[i].font[2], - bgcolor); + table[i].y0, + table[i].x0 + table[i].width, + table[i].y0 + table[i].font[2], + bgcolor); for (uint8_t k=0; ;k++) { if (txtp[k] == 0x00) @@ -639,7 +639,7 @@ break; } } - free(txt); + //free(txt); //dsp->copy_to_lcd(); pulse(1, false); } @@ -655,7 +655,7 @@ show(0x0C, "888", 3); // channel dsp show(0x0A, "\xFF\xFF\xFF\xFF", 4); // all flags dsp->copy_to_lcd(); - wait(3); + ThisThread::sleep_for(3); dsp->cls(); printf("TEST DSP #3\r\n"); @@ -681,7 +681,7 @@ printf("Copy ALL\n"); dsp->copy_to_lcd(); */ - wait(2); + ThisThread::sleep_for(2); dsp->cls(); printf("TEST DSP DONE\r\n"); } @@ -759,7 +759,7 @@ } } //else - Thread::wait(1); + ThisThread::sleep_for(1); } } @@ -792,6 +792,6 @@ while(1) { timeout_h(); - wait(1); + ThisThread::sleep_for(1); } }