Mon, 04 Oct 2021 21:14:39 +0200
Fix SHIFT and code cleanup
src/def_hp34970_fp.h | file | annotate | diff | comparison | revisions | |
src/main.cpp | file | annotate | diff | comparison | revisions |
--- a/src/def_hp34970_fp.h Sun Oct 03 22:58:49 2021 +0200 +++ b/src/def_hp34970_fp.h Mon Oct 04 21:14:39 2021 +0200 @@ -35,14 +35,8 @@ #define KP_C4 PB_0 #if defined(HAVE_PC) - #include <USBSerial.h> -#if 1 USBSerial pc(false); // PA_11 USB_DM, PA_12 USB_DP (with 1.5k pull-up) -#else -BufferedSerial pc(PC_10_ALT0, PC_11_ALT0, 115200); // UART_4 #endif #endif - -#endif
--- a/src/main.cpp Sun Oct 03 22:58:49 2021 +0200 +++ b/src/main.cpp Mon Oct 04 21:14:39 2021 +0200 @@ -11,14 +11,9 @@ #include "Keypad.h" // Pins and device declarations -#if defined TARGET_NUCLEO_F446RE -#include "def_f446re.h" -#elif defined TARGET_HP34970_FP_F303RD #include "def_hp34970_fp.h" -#endif #include "platform/CircularBuffer.h" -#include <USBSerial.h> Display *dsp; volatile bool splashscreen; @@ -111,41 +106,12 @@ void refresh_display(void); -void timeout_h() { -#if defined(HAS_LED) - led = !led; -#endif -} - -#ifdef DEBUG - -DigitalOut dbgpin(DBGPIN); -inline void pulse(uint8_t count=1, bool stayup=false) -{ - dbgpin = 0; - wait_us(2); - while (count--) - { - dbgpin = 1; - wait_us(2); - dbgpin = 0; - wait_us(2); - } - if (stayup) - dbgpin = 1; -} -#else -inline void pulse(uint8_t count=1, bool stayup=false) -{} -#endif - // callbacks & thread functions void reset(void); void reset_irq(void); void qei_cb(int dir); void end_splashscreen(void); - #if defined(HAVE_PC) FileHandle *mbed::mbed_override_console(int fd) { @@ -154,7 +120,6 @@ } #endif - void setup() { #if defined(HAVE_PC) pc.connect(); @@ -165,28 +130,19 @@ printf("\n\nSETUP\n"); printf(" System Core Clock = %ld MHZ\r\n", SystemCoreClock/1000000); - printf("Create USBSerial\n"); hp = NULL; - printf("Serial communication via UART4\r\n"); - printf("Setup HP communication pins\r\n"); - //printf(" HP_RX=%d\r\n", HP_RX); DigitalIn(HP_RX).mode(PullDown); - //printf(" HP_TX=%d\r\n", HP_TX); DigitalOut(HP_TX).write(1); - //printf(" HP_RST=%d\r\n", HP_RST); DigitalIn(HP_RST).mode(PullDown); printf(" setup QEI pins\r\n"); - //printf(" ENC1=%d\r\n", KP_ENC1); DigitalIn(KP_ENC1).mode(PullDown); - //printf(" ENC2=%d\r\n", KP_ENC2); DigitalIn(KP_ENC2).mode(PullDown); qenc.attach(&qei_cb); printf(" setup Keypad\r\n"); - shift = false; must_reset = false; must_shutdown = false; @@ -198,14 +154,6 @@ printf("Setup OLED display\r\n"); // init the LCD - /* - printf(" DSP_MOSI=%d\r\n", DSP_MOSI); - printf(" DSP_MISO=%d\r\n", DSP_MISO); - printf(" DSP_SCLK=%d\r\n", DSP_SCLK); - printf(" DSP_CS=%d\r\n", DSP_CS); - printf(" DSP_RST=%d\r\n", DSP_RST); - printf(" DSP_DC=%d\r\n", DSP_DC); - */ dsp = new Display(20000000, DSP_MOSI, DSP_MISO, DSP_SCLK, DSP_CS, DSP_RST, DSP_DC, "SSD1322"); @@ -263,25 +211,22 @@ splashscreen_timer.detach(); // same for splashscreen splashscreen = false; // in case it still on - if (hp == NULL) { - printf("setup HP communication handler\r\n"); - hp = new HPSerial(HP_TX, HP_RX); - } else { - printf("Connection already initialized\n"); - } - - printf("!! RST !! (gstate=%d, state=%d)\r\n", - hp->gstate(), hp->state()); - //printf("Value is ... %X\n", hp->search()); - dsp->power_on(); - dsp->cls(); - printf("Initiate startup sequence\n"); - if (last_key.keyevent == KEY_PRESSED) { - printf(" with key pressed\n"); - hp->send_startup_seq(kp_mapping[last_key.row][last_key.col]); - } else { - hp->send_startup_seq(); - } + if (hp == NULL) { + printf("setup HP communication handler\r\n"); + hp = new HPSerial(HP_TX, HP_RX); + } else { + printf("reset existing connection\n"); + hp->reset(); + } + dsp->power_on(); + dsp->cls(); + printf("Initiate startup sequence\n"); + if (last_key.keyevent == KEY_PRESSED) { + printf(" with key pressed\n"); + hp->send_startup_seq(kp_mapping[last_key.row][last_key.col]); + } else { + hp->send_startup_seq(); + } } else { @@ -312,6 +257,7 @@ for (uint8_t i=0; i<8; i++) err[i] = 0; + printf("Start the main loop\n"); while(1) { if (must_reset) { must_reset = false; @@ -352,7 +298,7 @@ if (shift) shift = false; else - shift = false; + shift = true; dsp->set_flag_status(0x0E, shift); dsp->draw_flag(0x0E); } @@ -385,9 +331,6 @@ { if (hp->pop(cmd)) { -#if defined(HAS_LED) - led = 1; -#endif for (uint8_t i=0; i<7; i++) if (hp->nerrors(i) > err[i]) { printf("ERR: %X/%X/%X/%X/%X/%X/%X\n", @@ -443,9 +386,6 @@ // display related commands dsp->show(cmd.cmd, cmd.value, cmd.size); } -#if defined(HAS_LED) - led = 0; -#endif } } //else @@ -483,6 +423,5 @@ int main() { setup(); - printf("Main loop (noop)\r\n"); mainloop(); }