M lib/keypad/Keypad.cpp +2 -2
@@ 47,7 47,7 @@ void Keypad::run()
{
// activate column col
_columns[col].write(1);
- ThisThread::sleep_for(5);
+ ThisThread::sleep_for(5ms);
for(row=0; row<_nrows; row++)
{
if (_rows[row].read())
@@ 71,7 71,7 @@ void Keypad::run()
}
_columns[col].write(0);
col = (col+1) % _ncols;
- ThisThread::sleep_for(5);
+ ThisThread::sleep_for(5ms);
}
}
M lib/keypad/Keypad.h +0 -2
@@ 1,4 1,3 @@
-
#ifndef KEYPAD_H
#define KEYPAD_H
@@ 7,7 6,6 @@
#include <vector>
-
typedef Callback<void(uint8_t, uint8_t)> keyevent_callback_t;
class Keypad {
M lib/unigraphic/GraphicsDisplay.cpp +8 -8
@@ 277,9 277,9 @@ void GraphicsDisplay::character(int x, i
{
char_x=x;
char_y=y;
- int j,i,b;
+ unsigned int j, i, b;
unsigned char* zeichen;
- unsigned char z,w,v, wtot;
+ unsigned char z, w, v, wtot;
/* // read font parameter from start of array
offset = font[0]; // bytes / char
@@ 301,6 301,8 @@ void GraphicsDisplay::character(int x, i
// so if the char to write crosses the width, do not display it
return;
}
+ wtot = 0;
+
if ((c < firstch) || (c > lastch)) { // test char range - if not exist fill with blank
window(char_x, char_y, fonthor*fontzoomhor, fontvert*fontzoomver); // char box
window_pushpixel(_background, fontzoomhor*fonthor*fontvert*fontzoomver); //(color, howmany)
@@ 353,7 355,7 @@ uint8_t GraphicsDisplay::char_width(char
void GraphicsDisplay::Bitmap_BW(Bitmap_s bm, int x, int y)
{
- int h,v,b;
+ unsigned int h,v,b;
// int cropX;
char d;
if(x<0) x=0;
@@ 376,17 378,15 @@ void GraphicsDisplay::Bitmap_BW(Bitmap_s
}
if(auto_up) copy_to_lcd();
}
-void GraphicsDisplay::Bitmap(int x, int y, int w, int h,unsigned char *bitmap)
+void GraphicsDisplay::Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h,unsigned char *bitmap)
{
int j;
unsigned char padd;
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;
- else if(x>=oriented_width) return;
- if(y<0) y=0;
- else if(y>=oriented_height) return;
+ if(x >= oriented_width) return;
+ if(y >= oriented_height) return;
int cropX = (x+w)-oriented_width;
if(cropX<0) cropX=0;
int cropY = (y+h)-oriented_height;
M lib/unigraphic/GraphicsDisplay.h +14 -15
@@ 42,9 42,9 @@
/** Bitmap
*/
struct Bitmap_s{
- int xSize;
- int ySize;
- int Byte_in_Line;
+ unsigned int xSize;
+ unsigned int ySize;
+ unsigned int Byte_in_Line;
char* data;
};
@@ 243,7 243,7 @@ public:
* cast the pointer to (unsigned char *) :
* tft.Bitmap(10,40,309,50,(unsigned char *)scala);
*/
- void Bitmap(int x, int y, int w, int h,unsigned char *bitmap);
+ void Bitmap(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap);
/** paint monochrome bitmap to screen
*
@@ 349,22 349,21 @@ public:
private:
-
unsigned char* font;
// display width and height related to current orientation
- int oriented_width;
- int oriented_height;
+ unsigned int oriented_width;
+ unsigned int oriented_height;
// text char location
- int char_x;
- int char_y;
+ unsigned int char_x;
+ unsigned int char_y;
- int fontoffset;// bytes / char (short)
- int fonthor; // hor size of font (char)
- int fontvert; // ver size of font (char)
- int fontbpl; // bytes per line (char)
- int fontzoomver; // size multiplier
- int fontzoomhor; // size multiplier
+ unsigned int fontoffset;// bytes / char (short)
+ unsigned int fonthor; // hor size of font (char)
+ unsigned int fontvert; // ver size of font (char)
+ unsigned int fontbpl; // bytes per line (char)
+ unsigned int fontzoomver; // size multiplier
+ unsigned int fontzoomhor; // size multiplier
unsigned char firstch; // first ascii code present in font array (usually 32)
unsigned char lastch; // last ascii code present in font array (usually 127)
bool auto_up; // autoupdate flag for LCD
M lib/unigraphic/SSD1322.cpp +10 -9
@@ 98,7 98,7 @@ SSD1322::SSD1322(int Hz, PinName mosi, P
const char *name)
: GraphicsDisplay(name),
screensize_X(DISPLAY_WIDTH), screensize_Y(DISPLAY_HEIGHT),
- _BPP(BPP), _PAGES(DISPLAY_HEIGHT/8*BPP),
+ _PAGES(DISPLAY_HEIGHT/8*BPP), _BPP(BPP),
_IC_X_SEGS(IC_X_SEGS), _IC_Y_COMS(IC_Y_COMS), _IC_PAGES(IC_Y_COMS/8*BPP),
_spi(mosi, miso, sclk),
_DC(DC), _CS(CS), _RST(reset)
@@ 138,13 138,13 @@ void SSD1322::wr_data8(unsigned char dat
void SSD1322::hw_reset()
{
- ThisThread::sleep_for(15);
+ ThisThread::sleep_for(15ms);
_DC = 1;
_CS = 1;
_RST = 0; // display reset
- ThisThread::sleep_for(2);
+ ThisThread::sleep_for(2ms);
_RST = 1; // end reset
- ThisThread::sleep_for(100);
+ ThisThread::sleep_for(100ms);
}
void SSD1322::bus_enable(bool enable)
@@ 188,7 188,7 @@ void SSD1322::mirrorXY(mirror_t mode)
// Enable Nibble Re-map,Scan from COM[N-1] to COM0,
// Disable COM Split Odd Even
// Enable Dual COM mode
- unsigned char d;
+ unsigned char d = 0;
switch (mode)
{
case(NONE):
@@ 324,9 324,10 @@ unsigned short SSD1322::pixelread(int x,
if((x >= screensize_X) || (y >= screensize_Y)) return 0;
unsigned short page = y * _BPP / 8;
+ /* to be used in correct implementation...
unsigned char pos = y & ((8 / _BPP) - 1); // position in page
unsigned char mask = (( 1 << _BPP) - 1);
-
+ */
//FAUX
return (_pixelBuffer[(x + page*screensize_X)]); // = (_pixelBuffer[(x + page*screensize_X)] & ~(mask<<(pos*_BPP))) | ((color&mask)<<(pos*_BPP));
}
@@ 355,9 356,6 @@ void SSD1322::set_column_address(unsigne
void SSD1322::copy_to_lcd(void)
{
- unsigned int x, y;
- unsigned int i;
-
pixel_buffer_mutex.lock();
memcpy((void*)_trBuffer,
(const void*)_pixelBuffer,
@@ 372,6 370,9 @@ void SSD1322::copy_to_lcd(void)
_CS = 0;
_spi.transfer((uint8_t*) _trBuffer, 64*128, (uint8_t*) NULL, 0, _spiEventCb);
#else
+ unsigned int x, y;
+ unsigned int i;
+
i = 0;
for(y=0; y<64; y++)
for(x=0; x<128; x++)
M lib/unigraphic/SSD1322.h +7 -7
@@ 207,13 207,6 @@ protected:
protected:
- mbed::SPI _spi;
- DigitalOut _CS;
- DigitalOut _RST;
- 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;
@@ 222,6 215,13 @@ protected:
const int _IC_Y_COMS;
const int _IC_PAGES;
+ mbed::SPI _spi;
+ DigitalOut _DC;
+ DigitalOut _CS;
+ DigitalOut _RST;
+ volatile DISPLAY_BUFFER_TYPE _pixelBuffer[DISPLAY_BUFFER_ELEMENTS]; // one full frame buffer
+ DISPLAY_BUFFER_TYPE _trBuffer[DISPLAY_BUFFER_ELEMENTS]; // for sending
+
// pixel location
int cur_x;
int cur_y;
M platformio.ini +3 -2
@@ 21,6 21,7 @@
platform = ststm32
framework = mbed
platform_packages =
+# framework-mbed @ file:///home/david/perso/embed/platformio/framework-mbed
framework-mbed @ https://github.com/douardda/mbed-os.git#platformio
board = hp34970_fp_f303rd
board_build.mbed.ldscript =
@@ 34,8 35,8 @@ upload_protocol = dfu
[env:fp_stlink]
platform = ststm32
framework = mbed
-platform_packages =
- framework-mbed @ https://github.com/douardda/mbed-os.git#platformio
+#platform_packages =
+# framework-mbed @ https://github.com/douardda/mbed-os.git#platformio
board = hp34970_fp_f303rd
board_build.mbed.ldscript =
$PROJECTSRC_DIR/../TARGET_HP34970_FP_F303RD/STM32F303XE.ld
R src/def_f446re.h => +0 -52
@@ 1,52 0,0 @@
-#if !defined(DEF_F446RE_H)
-
-
-#define DEF_F446RE_H
-/******************************************************/
-/* F446RE */
-/******************************************************/
-// TODO: use TARGET_NUCLEO_F446RE or similar
-// UART
-// USBTX PA_2
-// USBRX PA_3
-// display
-#define DSP_MOSI PB_15 // blue
-#define DSP_MISO PB_14 // NC
-#define DSP_SCLK PB_13 // yellow
-#define DSP_CS PB_12 // green
-#define DSP_RST PB_5 // green
-#define DSP_DC PB_4 // red
-
-// UART for RX (CPU->DP)
-#define HP_RX PC_11 // serial3 RX
-#define HP_TX PC_10 // serial3 TX
-
-// RST pin (handle this by hand)
-#define HP_RST PC_12
-
-// encoder
-#define KP_ENC1 PC_4
-#define KP_ENC2 PC_5
-
-// keypad
-#define KP_R0 PC_0 // I-6
-#define KP_R1 PC_1 // II-5
-#define KP_R2 PC_2 // I-5
-#define KP_R3 PC_3 // II-4
-
-
-#define KP_C0 PB_0 // I-4
-#define KP_C1 PA_6 // I-2
-#define KP_C2 PA_7 // I-3
-#define KP_C3 PA_10 // I-1
-#define KP_C4 PD_2 // II-1
-
-// misc
-#define DBGPIN PC_6
-
-#ifdef HAVE_PC
-BufferedSerial pc(USBTX, USBRX, 115200);
-#endif
-DigitalOut led(LED1);
-#define HAS_LED
-#endif
M src/display.cpp +0 -1
@@ 278,7 278,6 @@ void Display::set_flag_dim(uint8_t flagi
void Display::draw_flag(uint8_t flagid)
{
- uint8_t i;
uint8_t bgcolor = 0x00, fgcolor = 0x0F;
::printf(" FLAG %X:", flagid);
M src/hp34comm.cpp +9 -0
@@ 30,6 30,15 @@ HPSerial::HPSerial(PinName tx, PinName r
}
+void HPSerial::reset(void)
+{
+ sendbuf.reset();
+ cmdbuf.reset();
+ cur_state = STATE_IDLE;
+ cur_gstate = GSTATE_IDLE;
+}
+
+
// SEND related methods
void HPSerial::sendkey(uint8_t keycode)
{
M src/hp34comm.h +1 -0
@@ 25,6 25,7 @@ public:
HPSerial(PinName tx, PinName rx);
+ void reset(void);
bool cmd_available(void);
bool pop(CMD& cmd);
bool cmd_buf_full(void);