Several stuff draft

Thu, 15 Oct 2020 01:11:03 +0200

author
David Douard <david.douard@sdfa3.org>
date
Thu, 15 Oct 2020 01:11:03 +0200
changeset 26
86f099bda525
parent 25
5b1e0b384d31
child 27
8f2be7aaec00

Several stuff

README file | annotate | diff | comparison | revisions
lib/keypad/Keypad.cpp file | annotate | diff | comparison | revisions
lib/keypad/Keypad.h file | annotate | diff | comparison | revisions
lib/unigraphic/GraphicsDisplay.cpp file | annotate | diff | comparison | revisions
lib/unigraphic/SSD1322.cpp file | annotate | diff | comparison | revisions
lib/unigraphic/SSD1322.h file | annotate | diff | comparison | revisions
notes.rst file | annotate | diff | comparison | revisions
src/main.cpp file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README	Thu Oct 15 01:11:03 2020 +0200
@@ -0,0 +1,12 @@
+Use mbed 5.14
+
+For some reason I had to disable mbed-client-cli/ (multiple definition of `cmd' error at
+link time).
+Put a .mbedignore file in:
+
+$ cd /home/david/.platformio/packages/framework-mbed@6.51504.200716/features
+$ cat .mbedignore
+mbed-client-cli/*
+frameworks/mbed-client-cli/*
+
+see https://docs.platformio.org/en/latest/frameworks/mbed.html#ignoring-particular-components
--- a/lib/keypad/Keypad.cpp	Sun Aug 30 22:53:15 2020 +0200
+++ b/lib/keypad/Keypad.cpp	Thu Oct 15 01:11:03 2020 +0200
@@ -2,9 +2,12 @@
 #include "Keypad.h"
 
 
-Keypad::Keypad(uint8_t nRows, DigitalIn rows[],
-	       uint8_t nColumns, DigitalOut cols[],
-	       int debounce_ms):
+Keypad::Keypad(
+    uint8_t nRows,
+    DigitalIn rows[],
+    uint8_t nColumns,
+    DigitalOut cols[],
+    int debounce_ms):
   _rows(),
   _columns(),
   _debounce(debounce_ms),
@@ -13,12 +16,14 @@
   _ncols(nColumns)
 {
   printf("Setup Keypad: %dx%d\r\n", nColumns, nRows);
-  for(uint8_t c=0; c<nColumns; c++) {
+  for(uint8_t c=0; c<nColumns; c++)
+	{
     _columns.push_back(cols[c]);
     _columns[c].write(0);
   }
 
-  for(uint8_t r=0; r<nRows; r++) {
+  for(uint8_t r=0; r<nRows; r++)
+	{
     _rows.push_back(rows[r]);
     _rows[r].mode(PullDown);
   }
@@ -37,29 +42,31 @@
 
   for (row=0; row<(_ncols*_nrows); row++)
     _keys[row] = 0;
-  while(_started) {
+
+  while(_started)
+  {
     _columns[col].write(1);
     Thread::wait(5);
     for(row=0; row<_nrows; row++)
+    {
+      if (_rows[row].read())
       {
-	if (_rows[row].read())
-	  {
-	    if (_keys[row + _nrows*col] < 2)
-	      {
-		_keys[row + _nrows*col]++;
-		if ((_keys[row + _nrows*col] == 2) && _kp_callback)
-		  _kp_callback.call(row, col);
-	      }
-	  }
-	else
-	  {
-	    if (_keys[row + _nrows*col] > 0)
-	      {
-		_keys[row + _nrows*col]--;
-		if ((_keys[row + _nrows*col] == 0) && _kr_callback)
-		  _kr_callback.call(row, col);
-	      }
-	  }
+        if (_keys[row + _nrows*col] < 2)
+        {
+          _keys[row + _nrows*col]++;
+          if ((_keys[row + _nrows*col] == 2) && _kp_callback)
+            _kp_callback.call(row, col);
+        }
+      }
+      else
+      {
+        if (_keys[row + _nrows*col] > 0)
+        {
+          _keys[row + _nrows*col]--;
+          if ((_keys[row + _nrows*col] == 0) && _kr_callback)
+            _kr_callback.call(row, col);
+        }
+      }
       }
     _columns[col].write(0);
     col = (col+1) % _ncols;
@@ -68,7 +75,7 @@
 }
 
 void Keypad::attach(const keyevent_callback_t& kp_callback,
-		      const keyevent_callback_t& kr_callback)
+										const keyevent_callback_t& kr_callback)
 {
   _kp_callback = kp_callback;
   _kr_callback = kr_callback;
--- a/lib/keypad/Keypad.h	Sun Aug 30 22:53:15 2020 +0200
+++ b/lib/keypad/Keypad.h	Thu Oct 15 01:11:03 2020 +0200
@@ -3,7 +3,7 @@
 #define KEYPAD_H
 
 #include "mbed.h"
-#include "rtos.h"
+//#include "rtos.h"
 #include <vector>
 
 
@@ -15,18 +15,18 @@
   Keypad(uint8_t nRows, DigitalIn rows[],
 	 uint8_t nColumns, DigitalOut cols[],
 	 int debounce_ms=20);
-    
+
   /** Destructor
    */
   ~Keypad();
-  
+
   void attach(const keyevent_callback_t& kp_callback=NULL,
 	      const keyevent_callback_t& kr_callback=NULL);
-  
+
   void start(void);
   void stop(void);
-  
-  
+
+
 protected:
   std::vector<DigitalIn> _rows;
   std::vector<DigitalOut> _columns;
@@ -37,7 +37,7 @@
   void _keyPressed(int row);
   void _keyReleased(int row);
   void run();
-  
+
 private:
   keyevent_callback_t _kp_callback;
   keyevent_callback_t _kr_callback;
--- a/lib/unigraphic/GraphicsDisplay.cpp	Sun Aug 30 22:53:15 2020 +0200
+++ b/lib/unigraphic/GraphicsDisplay.cpp	Thu Oct 15 01:11:03 2020 +0200
@@ -19,10 +19,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
- 
+
 
- 
 #include "GraphicsDisplay.h"
+
 #define SWAP(a, b)  { a ^= b; b ^= a; a ^= b; }
 GraphicsDisplay::GraphicsDisplay(const char *name):TextDisplay(name) {
     set_font((unsigned char*)Terminal6x8,32,127,true);
@@ -36,7 +36,7 @@
     fontzoomhor=1;
     auto_up = true;
 }
-    
+
 void GraphicsDisplay::WindowMax (void)
 {
     window (0, 0, oriented_width,  oriented_height);
@@ -210,7 +210,7 @@
 {
     if(x0 > x1) SWAP(x0,x1);
     if(y0 > y1) SWAP(y0,y1);
-     
+
     int h = y1 - y0 + 1;
     int w = x1 - x0 + 1;
     unsigned int pixels = h * w;
@@ -326,7 +326,7 @@
     if(x<0) x=0;
     if(y<0) y=0;
     int cropX = (x+bm.xSize)-oriented_width;
-    if(cropX<0) cropX=0; 
+    if(cropX<0) cropX=0;
     window(x, y, bm.xSize-cropX, bm.ySize);
     for(v=0; v < bm.ySize; v++) {   // lines
         if((v + y) >= oriented_height) break; // no need to crop Y
@@ -347,7 +347,7 @@
 {
     int  j;
     unsigned char  padd;
-    unsigned short *bitmap_ptr = (unsigned short *)bitmap;    
+    unsigned short *bitmap_ptr = (unsigned short *)bitmap;
 
     padd = w%2; // the lines are padded to multiple of 4 bytes in a bitmap
     if(x<0) x=0;
@@ -391,8 +391,8 @@
     while (*Name_BMP!='\0') {
         filename[i++]=*Name_BMP++;
     }
-    filename[i] = 0;  
-    
+    filename[i] = 0;
+
     FILE *Image = fopen((const char *)&filename[0], "rb");  // open the bmp file
     if (!Image) {
         return(0);      // error file not found !
@@ -436,12 +436,12 @@
     for (j = PixelHeigh - 1; j >= 0; j--) {               //Lines bottom up
         off = j * (PixelWidth  * 2 + padd) + start_data;   // start of line
         fseek(Image, off ,SEEK_SET);
-        fread(line,1,PixelWidth * 2,Image);       // read a line - slow 
+        fread(line,1,PixelWidth * 2,Image);       // read a line - slow
   /*      for (i = 0; i < PixelWidth; i++)
         {        // copy pixel data to TFT
-     //       wr_16(line[i]);                  // one 16 bit pixel   
+     //       wr_16(line[i]);                  // one 16 bit pixel
             window_pushpixel(line[i]);
-            
+
         } */
         window_pushpixelbuf(line, PixelWidth);
      }
@@ -469,5 +469,3 @@
 {
     return (auto_up);
 }
-
-
--- a/lib/unigraphic/SSD1322.cpp	Sun Aug 30 22:53:15 2020 +0200
+++ b/lib/unigraphic/SSD1322.cpp	Thu Oct 15 01:11:03 2020 +0200
@@ -2,7 +2,7 @@
  * Copyright (c) 2015 Peter Drescher
  * Released under the MIT License: http://mbed.org/license/mit
  */
-  
+
 #include "platform.h"
 #include "SSD1322.h"
 
@@ -46,7 +46,7 @@
 #define SSD1322_CMD_DISPLAY_ENHANCEMENT_B	0xD1
 #define SSD1322_CMD_SET_COMMAND_LOCK		0xFD
 
-// set for some OLED displays 
+// set for some OLED displays
 //#define ALTERNATE_OLED_VERSION
 
 
@@ -95,7 +95,7 @@
 
 
 SSD1322::SSD1322(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC,
-		 const char *name) 
+		 const char *name)
     : GraphicsDisplay(name),
       screensize_X(DISPLAY_WIDTH), screensize_Y(DISPLAY_HEIGHT),
       _BPP(BPP), _PAGES(DISPLAY_HEIGHT/8*BPP),
@@ -164,7 +164,7 @@
     } else {
       set_width(screensize_Y);
       set_height(screensize_X);
-    }      
+    }
     switch (o) {
     case (0):// portrait view -90°
       mirrorXY(Y);
@@ -202,11 +202,11 @@
       break;
     case(XY):
       d = 0x12;
-      break;	    
+      break;
     }
-  wr_cmd8(SSD1322_CMD_SET_REMAP); 
+  wr_cmd8(SSD1322_CMD_SET_REMAP);
   wr_data8(d);
-  wr_data8(0x11); 
+  wr_data8(0x11);
 }
 
 void SSD1322::invert(unsigned char o)
@@ -265,6 +265,7 @@
       count--;
     }
 }
+
 void SSD1322::window_pushpixelbuf(unsigned short* color, unsigned int lenght) {
   while(lenght)
     {
@@ -360,8 +361,9 @@
   set_column_address(0);
 
   memcpy((void*)_trBuffer,
-	 (const void*)_pixelBuffer,
-	 DISPLAY_BUFFER_ELEMENTS * sizeof(DISPLAY_BUFFER_TYPE));
+		 (const void*)_pixelBuffer,
+		 DISPLAY_BUFFER_ELEMENTS * sizeof(DISPLAY_BUFFER_TYPE));
+
   wr_cmd8(SSD1322_CMD_WRITE_RAM);
 
 #ifdef DEVICE_SPI_ASYNCH
@@ -369,8 +371,8 @@
   _spi.transfer((uint8_t*) _trBuffer, 64*128, (uint8_t*) NULL, 0, _spiEventCb);
 #else
   i = 0;
-  for(y=0; y<64; y++) 
-    for(x=0; x<128; x++) 
+  for(y=0; y<64; y++)
+    for(x=0; x<128; x++)
       wr_data8(_trBuffer[i++]);
 #endif
 }
@@ -385,15 +387,15 @@
     to_row = 0x3F;
 
   memcpy((void*)_trBuffer,
-	 (const void*)_pixelBuffer,
-	 DISPLAY_BUFFER_ELEMENTS * sizeof(DISPLAY_BUFFER_TYPE));
-  
+		 (const void*)_pixelBuffer,
+		 DISPLAY_BUFFER_ELEMENTS * sizeof(DISPLAY_BUFFER_TYPE));
+
   set_row_address(from_row, to_row);
   set_column_address(from_col, to_col);
 
   wr_cmd8(SSD1322_CMD_WRITE_RAM);
   for(y=from_row; y<=to_row; y++) {
-    for(x=from_col; x<=to_col; x++) { 
+    for(x=from_col; x<=to_col; x++) {
       wr_data8(_trBuffer[y*128 + 2*x]);
       wr_data8(_trBuffer[y*128 + 2*x + 1]);
     }
--- a/lib/unigraphic/SSD1322.h	Sun Aug 30 22:53:15 2020 +0200
+++ b/lib/unigraphic/SSD1322.h	Thu Oct 15 01:11:03 2020 +0200
@@ -30,22 +30,22 @@
 class SSD1322: public GraphicsDisplay
 {
 
-public:         
+public:
 
-  
+
     /** Create a monochrome SSD1322 SPI interface
-    * @param name The name used by the parent class to access the interface
-    */
-  SSD1322(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC,
-	  const char* name);
-    
+	 * @param name The name used by the parent class to access the interface
+	 */
+	SSD1322(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC,
+			const char* name);
+
     /** Destructor
-    * will free framebuffer
-    */
+	 * will free framebuffer
+	 */
     virtual ~SSD1322() {};
-    
+
 
-    
+
 /////// functions that come for free, but can be overwritten///////////////////////////////////////////////////
 /////// ----------------------------------------------------///////////////////////////////////////////////////
 
@@ -66,7 +66,7 @@
     * @param h is the window height in pixels.
     */
     virtual void window(int x, int y, int w, int h);
-    
+
     /** Read pixel color at location
     * @param x is the horizontal offset to this pixel.
     * @param y is the vertical offset to this pixel.
@@ -79,24 +79,24 @@
     * @param color is the pixel color.
     */
     virtual void window_pushpixel(unsigned short color);
-    
+
     /** Push some pixels of the same color into the window and increment position.
     * You must first call window() then push pixels.
     * @param color is the pixel color.
     * @param count: how many
     */
     virtual void window_pushpixel(unsigned short color, unsigned int count);
-    
+
     /** Push array of pixel colors into the window and increment position.
     * You must first call window() then push pixels.
     * @param color is the pixel color.
     */
     virtual void window_pushpixelbuf(unsigned short* color, unsigned int lenght);
- 
+
     /** Framebuffer is used, it needs to be sent to SSD1322 from time to time
     */
     virtual void copy_to_lcd();
-    
+
     /** set the contrast of the screen
       *
       * @param o contrast 0-63
@@ -120,9 +120,9 @@
     * We override it to speedup
     */
     virtual void cls();
-    
+
     /** Set the orientation of the screen
-    *  x,y: 0,0 is always top left 
+    *  x,y: 0,0 is always top left
     *
     * @param o direction to use the screen (0-3)
     * 0 = -90°
@@ -130,14 +130,14 @@
     * 2 = +90°
     * 3 = +180°
     *
-    */  
+    */
     void set_orientation(int o);
-    
+
     /** Set ChipSelect high or low
-    * @param enable 0/1   
+    * @param enable 0/1
     */
     virtual void bus_enable(bool enable);
-    
+
     /** get display X size in pixels (native, orientation independent)
     * @returns X size in pixels
     */
@@ -147,8 +147,8 @@
     * @returns Y size in pixels
     */
     int sizeY() {return screensize_Y;};
-    
-////////////////////////////////////////////////////////////////////////////////    
+
+////////////////////////////////////////////////////////////////////////////////
     // not implemented yet
 //////////////////////////////////////////////////////////////////
   //  virtual unsigned short pixelread(int x, int y){return 0;};
@@ -163,47 +163,47 @@
     void clrbuff(const unsigned char value=0x00);
     unsigned long buffaddr(unsigned int i);
     void fills(const unsigned char value=0xFF);
-    
+
     void set_row_address(unsigned char start_row=0x00, unsigned char end_row=0x3F);
     void set_column_address(unsigned char start_col=0x00, unsigned char end_col=0x3F);
 
     virtual void copy_to_lcd(unsigned char from_col, unsigned char to_col,
-			     unsigned char from_row, unsigned char to_row);
-    
+							 unsigned char from_row, unsigned char to_row);
+
 protected:
     /** Setup some stuff (malloc the buffer, etc)
     */
     void init();
 
     /** set mirror mode
-      * @note may be overridden by specific display init class in case of not standard cmds or inverted wiring 
-      * @param mode NONE, X, Y, XY 
+      * @note may be overridden by specific display init class in case of not standard cmds or inverted wiring
+      * @param mode NONE, X, Y, XY
       */
     virtual void mirrorXY(mirror_t mode);
 
 ////// functions needed by parent class ///////////////////////////////////////
 ////// -------------------------------- ///////////////////////////////////////
 
-    /** Send 8bit command to display controller 
+    /** Send 8bit command to display controller
     *
-    * @param cmd: byte to send  
+    * @param cmd: byte to send
     * @note if protocol is SPI16, it will insert NOP cmd before, so if cmd is a 2byte cmd, the second cmd will be broken. Use wr_cmd16 for 2bytes cmds
-    */   
+    */
     void wr_cmd8(unsigned char cmd);
-    
-    /** Send 8bit data to display controller 
+
+    /** Send 8bit data to display controller
     *
-    * @param data: byte to send   
+    * @param data: byte to send
     *
-    */   
+    */
     void wr_data8(unsigned char data);
-        
-    /** HW reset sequence (without display init commands)   
+
+    /** HW reset sequence (without display init commands)
     */
     void hw_reset();
-  
+
     int contrast;
-    
+
 protected:
 
     mbed::SPI _spi;
@@ -212,7 +212,7 @@
     DigitalOut _DC;
     volatile DISPLAY_BUFFER_TYPE _pixelBuffer[DISPLAY_BUFFER_ELEMENTS]; // one full frame buffer
     DISPLAY_BUFFER_TYPE _trBuffer[DISPLAY_BUFFER_ELEMENTS]; // for sending
-    
+
     const int screensize_X;
     const int screensize_Y;
     const int _PAGES;
@@ -235,7 +235,7 @@
 #ifdef DEVICE_SPI_ASYNCH
     event_callback_t _spiEventCb;
 #endif
-    
+
 };
 
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/notes.rst	Thu Oct 15 01:11:03 2020 +0200
@@ -0,0 +1,149 @@
+Probing
+=======
+
+Serial probe with dslogic in serialdata/
+
+read-sr: Decode the raw capture (34970-long-session.sr) and display the protocol
+
+  serialdata$ cat read-sr  | sh
+
+  00007553 [+0.01] >>> CHANNEL 	203
+  00007573 [+0.02] >>> DISPLAY 	MUX      OPEN
+  00007581 [+0.01] >>> CHANNEL 	203
+  00007589 [+0.01] <<< KNOB		Knob left
+  00007640 [+0.05] <<< KNOB		Knob left
+  00007645 [+0.01] >>> DISPLAY 	MUX      OPEN
+  00007654 [+0.01] >>> CHANNEL 	202
+  00007674 [+0.02] >>> DISPLAY 	MUX      OPEN
+  00007682 [+0.01] >>> CHANNEL 	202
+  00007697 [+0.02] <<< KNOB		Knob left
+  00007745 [+0.05] <<< KNOB		Knob left
+  00007750 [+0.01] >>> DISPLAY 	MUX      OPEN
+  00007759 [+0.01] >>> CHANNEL 	201
+
+read-sd-continuous: Should read continuously the data stream from the dslogic...
+
+
+Protocol
+========
+
+> = cpu -> dsp
+< = dsp -> cpu
+
+0x80 -> right
+0x81 -> left
+
+shitf + key -> bit 5
+key release -> bit 6
+
+End of shift packet:
+>66 <99 >01 <00 >01 <00 >0E <00 >55
+
+
+init    -> <33 >CC <02 >00 <00 >00 <55
++ shift -> <33 >CC <02 >00 <FF >00 <0C >00 <55
++ scan  -> <33 >CC <02 >00 <FF >00 <03 >00 <55
+
+shutdown ->
+  cpu -> cmd 0x86 + 0x55 ad libidum
+  ie >66 <99 >86 <00 >55 >55 >55 ...
+
+commands:
+
+0x00 -> display text
+  >66 <99 >00 <00 >nn <00 >c1 <00 ... >cn <00 >55
+0x0A -> flags
+  >66 <99 >0A <00 >04 <00 >f0 <00 >f1 <00 >f2 <00 >f3 <00 >55
+0x0C -> display channels
+
+0x02 -> ???
+ >02 <?? >01 <??
+
+
+
+
+
+flags
+
+f1 b7 -> alarm frame
+F4 b1 -> SCAN
+
+
+once + scan -> 0C > 00 > 20 > 20
+
+view + last + min + max + avg ->
+  0A: 0C / 80 / 07 / 08
+  08: 01 / 0F
+
+
+view + last + min + max + avg*
+  0A: 0C / 80 / 07 / 08
+  09: 01 / 0F
+
+view + last + min + max* + avg
+  08: 01 0F
+  09: 01 10
+
+
+view + last + min* + max + avg (DATE)
+  08: 01 / 10
+  09: 01 / 11
+view + last + min* + max + avg (DIN)
+  08: 01 / 11
+  09: 01 / 11
+
+last* + min + max + avg (DIN)
+ DIN
+  08 01 12
+  09 01 12
+ DATE
+  08 01 12
+  09 01 12
+
+08 -> low bright
+09 -> hi bright
+
+sortie du mode "view" on a a la suite:
+  09 01 12
+  09 01 11
+  09 01 10
+  09 01 0F
+
+on a aussi un paquet 02 01 0C (clear?)
+
+
+
+Mode VIEW pour DIN
+==================
+
+quand on rentre en mode "view":
+
+- 02 01 99 (?)
+- 0A / 0C 00 00 00
+- 0A / 0C 00 00 08
+- text  READINGS
+
+puis View (Readings)
+
+- 0A / 0C 00 00 08
+- channel
+- 0A / 0C 00 00 08
+- 0A / 0C 00 00 08
+- 09 / 01 12 (LAST en hi bright)
+- 0A / 0C 80 07 08
+- 08 / 01 11
+- 08 / 01 10
+- 08 / 01 0F
+- text (value)
+
+puis ->
+
+- 08 / 01 12
+- 09 / 01 12
+- textes
+
+
+PCB
+===
+
+18.3 x 7.8
--- 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; i<sizeof(table)/sizeof(table[0]); ++i) {
 			if (table[i].cmd == cmd) {
@@ -527,16 +527,16 @@
 
 				dsp->locate(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);
   }
 }

mercurial