From e6d4ecc5ba142fbd99df1ea245f8f79b5c034557 Mon Sep 17 00:00:00 2001 From: Hans Haupt Date: Wed, 29 May 2024 22:56:53 +0200 Subject: [PATCH] adopted print method, changed stringtermination to \0 termination --- src/display/CharTable.h | 128 ++++++++++++++++++++++++++++++++++++++++ src/display/Display.cpp | 55 +++++++++-------- src/display/Display.h | 2 - 3 files changed, 157 insertions(+), 28 deletions(-) create mode 100644 src/display/CharTable.h diff --git a/src/display/CharTable.h b/src/display/CharTable.h new file mode 100644 index 0000000..beb723e --- /dev/null +++ b/src/display/CharTable.h @@ -0,0 +1,128 @@ +const char font8x8_colwise[128][9] = {{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+0() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+1() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+2() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+3() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+4() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+5() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+6() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+7() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+8() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+9() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+a() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+b() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+c() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+d() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+e() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+f() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+10() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+11() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+12() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+13() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+14() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+15() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+16() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+17() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+18() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+19() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+1a() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+1b() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+1c() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+1d() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+1e() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+1f() +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // U+20( ) +{ 0x40,0x00,0x00,0x06,0x5f,0x5f,0x06,0x00,0x00}, // U+21(!) +{ 0x40,0x00,0x03,0x03,0x00,0x03,0x03,0x00,0x00}, // U+22(") +{ 0x40,0x14,0x7f,0x7f,0x14,0x7f,0x7f,0x14,0x00}, // U+23(#) +{ 0x40,0x24,0x2e,0x6b,0x6b,0x3a,0x12,0x00,0x00}, // U+24($) +{ 0x40,0x46,0x66,0x30,0x18,0x0c,0x66,0x62,0x00}, // U+25(%) +{ 0x40,0x30,0x7a,0x4f,0x5d,0x37,0x7a,0x48,0x00}, // U+26(&) +{ 0x40,0x04,0x07,0x03,0x00,0x00,0x00,0x00,0x00}, // U+27(') +{ 0x40,0x00,0x1c,0x3e,0x63,0x41,0x00,0x00,0x00}, // U+28(() +{ 0x40,0x00,0x41,0x63,0x3e,0x1c,0x00,0x00,0x00}, // U+29()) +{ 0x40,0x08,0x2a,0x3e,0x1c,0x1c,0x3e,0x2a,0x08}, // U+2a(*) +{ 0x40,0x08,0x08,0x3e,0x3e,0x08,0x08,0x00,0x00}, // U+2b(+) +{ 0x40,0x00,0x80,0xe0,0x60,0x00,0x00,0x00,0x00}, // U+2c(,) +{ 0x40,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00}, // U+2d(-) +{ 0x40,0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x00}, // U+2e(.) +{ 0x40,0x60,0x30,0x18,0x0c,0x06,0x03,0x01,0x00}, // U+2f(/) +{ 0x40,0x3e,0x7f,0x71,0x59,0x4d,0x7f,0x3e,0x00}, // U+30(0) +{ 0x40,0x40,0x42,0x7f,0x7f,0x40,0x40,0x00,0x00}, // U+31(1) +{ 0x40,0x62,0x73,0x59,0x49,0x6f,0x66,0x00,0x00}, // U+32(2) +{ 0x40,0x22,0x63,0x49,0x49,0x7f,0x36,0x00,0x00}, // U+33(3) +{ 0x40,0x18,0x1c,0x16,0x53,0x7f,0x7f,0x50,0x00}, // U+34(4) +{ 0x40,0x27,0x67,0x45,0x45,0x7d,0x39,0x00,0x00}, // U+35(5) +{ 0x40,0x3c,0x7e,0x4b,0x49,0x79,0x30,0x00,0x00}, // U+36(6) +{ 0x40,0x03,0x03,0x71,0x79,0x0f,0x07,0x00,0x00}, // U+37(7) +{ 0x40,0x36,0x7f,0x49,0x49,0x7f,0x36,0x00,0x00}, // U+38(8) +{ 0x40,0x06,0x4f,0x49,0x69,0x3f,0x1e,0x00,0x00}, // U+39(9) +{ 0x40,0x00,0x00,0x66,0x66,0x00,0x00,0x00,0x00}, // U+3a(:) +{ 0x40,0x00,0x80,0xe6,0x66,0x00,0x00,0x00,0x00}, // U+3b(;) +{ 0x40,0x08,0x1c,0x36,0x63,0x41,0x00,0x00,0x00}, // U+3c(<) +{ 0x40,0x24,0x24,0x24,0x24,0x24,0x24,0x00,0x00}, // U+3d(=) +{ 0x40,0x00,0x41,0x63,0x36,0x1c,0x08,0x00,0x00}, // U+3e(>) +{ 0x40,0x02,0x03,0x51,0x59,0x0f,0x06,0x00,0x00}, // U+3f(?) +{ 0x40,0x3e,0x7f,0x41,0x5d,0x5d,0x1f,0x1e,0x00}, // U+40(@) +{ 0x40,0x7c,0x7e,0x13,0x13,0x7e,0x7c,0x00,0x00}, // U+41(A) +{ 0x40,0x41,0x7f,0x7f,0x49,0x49,0x7f,0x36,0x00}, // U+42(B) +{ 0x40,0x1c,0x3e,0x63,0x41,0x41,0x63,0x22,0x00}, // U+43(C) +{ 0x40,0x41,0x7f,0x7f,0x41,0x63,0x3e,0x1c,0x00}, // U+44(D) +{ 0x40,0x41,0x7f,0x7f,0x49,0x5d,0x41,0x63,0x00}, // U+45(E) +{ 0x40,0x41,0x7f,0x7f,0x49,0x1d,0x01,0x03,0x00}, // U+46(F) +{ 0x40,0x1c,0x3e,0x63,0x41,0x51,0x73,0x72,0x00}, // U+47(G) +{ 0x40,0x7f,0x7f,0x08,0x08,0x7f,0x7f,0x00,0x00}, // U+48(H) +{ 0x40,0x00,0x41,0x7f,0x7f,0x41,0x00,0x00,0x00}, // U+49(I) +{ 0x40,0x30,0x70,0x40,0x41,0x7f,0x3f,0x01,0x00}, // U+4a(J) +{ 0x40,0x41,0x7f,0x7f,0x08,0x1c,0x77,0x63,0x00}, // U+4b(K) +{ 0x40,0x41,0x7f,0x7f,0x41,0x40,0x60,0x70,0x00}, // U+4c(L) +{ 0x40,0x7f,0x7f,0x0e,0x1c,0x0e,0x7f,0x7f,0x00}, // U+4d(M) +{ 0x40,0x7f,0x7f,0x06,0x0c,0x18,0x7f,0x7f,0x00}, // U+4e(N) +{ 0x40,0x1c,0x3e,0x63,0x41,0x63,0x3e,0x1c,0x00}, // U+4f(O) +{ 0x40,0x41,0x7f,0x7f,0x49,0x09,0x0f,0x06,0x00}, // U+50(P) +{ 0x40,0x1e,0x3f,0x21,0x71,0x7f,0x5e,0x00,0x00}, // U+51(Q) +{ 0x40,0x41,0x7f,0x7f,0x09,0x19,0x7f,0x66,0x00}, // U+52(R) +{ 0x40,0x26,0x6f,0x4d,0x59,0x73,0x32,0x00,0x00}, // U+53(S) +{ 0x40,0x03,0x41,0x7f,0x7f,0x41,0x03,0x00,0x00}, // U+54(T) +{ 0x40,0x7f,0x7f,0x40,0x40,0x7f,0x7f,0x00,0x00}, // U+55(U) +{ 0x40,0x1f,0x3f,0x60,0x60,0x3f,0x1f,0x00,0x00}, // U+56(V) +{ 0x40,0x7f,0x7f,0x30,0x18,0x30,0x7f,0x7f,0x00}, // U+57(W) +{ 0x40,0x43,0x67,0x3c,0x18,0x3c,0x67,0x43,0x00}, // U+58(X) +{ 0x40,0x07,0x4f,0x78,0x78,0x4f,0x07,0x00,0x00}, // U+59(Y) +{ 0x40,0x47,0x63,0x71,0x59,0x4d,0x67,0x73,0x00}, // U+5a(Z) +{ 0x40,0x00,0x7f,0x7f,0x41,0x41,0x00,0x00,0x00}, // U+5b([) +{ 0x40,0x01,0x03,0x06,0x0c,0x18,0x30,0x60,0x00}, // U+5c(\) +{ 0x40,0x00,0x41,0x41,0x7f,0x7f,0x00,0x00,0x00}, // U+5d(]) +{ 0x40,0x08,0x0c,0x06,0x03,0x06,0x0c,0x08,0x00}, // U+5e(^) +{ 0x40,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, // U+5f(_) +{ 0x40,0x00,0x00,0x03,0x07,0x04,0x00,0x00,0x00}, // U+60(`) +{ 0x40,0x20,0x74,0x54,0x54,0x3c,0x78,0x40,0x00}, // U+61(a) +{ 0x40,0x41,0x7f,0x3f,0x48,0x48,0x78,0x30,0x00}, // U+62(b) +{ 0x40,0x38,0x7c,0x44,0x44,0x6c,0x28,0x00,0x00}, // U+63(c) +{ 0x40,0x30,0x78,0x48,0x49,0x3f,0x7f,0x40,0x00}, // U+64(d) +{ 0x40,0x38,0x7c,0x54,0x54,0x5c,0x18,0x00,0x00}, // U+65(e) +{ 0x40,0x48,0x7e,0x7f,0x49,0x03,0x02,0x00,0x00}, // U+66(f) +{ 0x40,0x98,0xbc,0xa4,0xa4,0xf8,0x7c,0x04,0x00}, // U+67(g) +{ 0x40,0x41,0x7f,0x7f,0x08,0x04,0x7c,0x78,0x00}, // U+68(h) +{ 0x40,0x00,0x44,0x7d,0x7d,0x40,0x00,0x00,0x00}, // U+69(i) +{ 0x40,0x60,0xe0,0x80,0x80,0xfd,0x7d,0x00,0x00}, // U+6a(j) +{ 0x40,0x41,0x7f,0x7f,0x10,0x38,0x6c,0x44,0x00}, // U+6b(k) +{ 0x40,0x00,0x41,0x7f,0x7f,0x40,0x00,0x00,0x00}, // U+6c(l) +{ 0x40,0x7c,0x7c,0x18,0x38,0x1c,0x7c,0x78,0x00}, // U+6d(m) +{ 0x40,0x7c,0x7c,0x04,0x04,0x7c,0x78,0x00,0x00}, // U+6e(n) +{ 0x40,0x38,0x7c,0x44,0x44,0x7c,0x38,0x00,0x00}, // U+6f(o) +{ 0x40,0x84,0xfc,0xf8,0xa4,0x24,0x3c,0x18,0x00}, // U+70(p) +{ 0x40,0x18,0x3c,0x24,0xa4,0xf8,0xfc,0x84,0x00}, // U+71(q) +{ 0x40,0x44,0x7c,0x78,0x4c,0x04,0x1c,0x18,0x00}, // U+72(r) +{ 0x40,0x48,0x5c,0x54,0x54,0x74,0x24,0x00,0x00}, // U+73(s) +{ 0x40,0x00,0x04,0x3e,0x7f,0x44,0x24,0x00,0x00}, // U+74(t) +{ 0x40,0x3c,0x7c,0x40,0x40,0x3c,0x7c,0x40,0x00}, // U+75(u) +{ 0x40,0x1c,0x3c,0x60,0x60,0x3c,0x1c,0x00,0x00}, // U+76(v) +{ 0x40,0x3c,0x7c,0x70,0x38,0x70,0x7c,0x3c,0x00}, // U+77(w) +{ 0x40,0x44,0x6c,0x38,0x10,0x38,0x6c,0x44,0x00}, // U+78(x) +{ 0x40,0x9c,0xbc,0xa0,0xa0,0xfc,0x7c,0x00,0x00}, // U+79(y) +{ 0x40,0x4c,0x64,0x74,0x5c,0x4c,0x64,0x00,0x00}, // U+7a(z) +{ 0x40,0x08,0x08,0x3e,0x77,0x41,0x41,0x00,0x00}, // U+7b({) +{ 0x40,0x00,0x00,0x00,0x77,0x77,0x00,0x00,0x00}, // U+7c(|) +{ 0x40,0x41,0x41,0x77,0x3e,0x08,0x08,0x00,0x00}, // U+7d(}) +{ 0x40,0x02,0x03,0x01,0x03,0x02,0x03,0x01,0x00}, // U+7e(~) +{ 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}; // U+7f(°) \ No newline at end of file diff --git a/src/display/Display.cpp b/src/display/Display.cpp index b54b8bd..17cf867 100644 --- a/src/display/Display.cpp +++ b/src/display/Display.cpp @@ -1,4 +1,5 @@ -#include Display.h +#include "Display.h" +#include "CharTable.h" void Display::sendDisplayCMD(uint8_t cmd){ @@ -98,60 +99,62 @@ void Display::updateLine(int charAmount) void Display::print(char *value){ int i = 0; - int charval; - int nextchar; + char nextchar; /* write data to the buffer */ - //check if input is a predefined cmd - for(i=0;icurrLine = 0; + this->charsOnCurrLine = 0; } else if(nextchar=='n') { - if(charsOnCurrLine==16) + if(this->charsOnCurrLine==16) { - currLine=currLine+1; - charsOnCurrLine=0; + this->currLine=currLine+1; + this->charsOnCurrLine=0; } - while(charsOnCurrLine<17) + while(this->charsOnCurrLine<17) { - i2c_master_send(display_i2c_client,font8x8_colwise[0],9); + Wire.beginTransmission(Display_Adress); + for(int i = 0;i<9;i++){ + Wire.write(font8x8_colwise[0][i]); + } + Wire.endTransmission(); updateLine(1); if(charsOnCurrLine==16) { break; } } - } - else - { - } i=i+1; } else { updateLine(1); - i2c_master_send(display_i2c_client,font8x8_colwise[charval],9); + Wire.beginTransmission(DisplayAdress); + for(int i = 0;i<9;i++){ + Wire.write(font8x8_colwise[*value][i]); + } + Wire.endTransmission(); } } // } - - - return procfs_buffer_size; -} + return; + }; void Display::println(char *value){ }; -void Display::print(int value); \ No newline at end of file +void Display::print(int value){ + +}; \ No newline at end of file diff --git a/src/display/Display.h b/src/display/Display.h index 91082ed..b2be961 100644 --- a/src/display/Display.h +++ b/src/display/Display.h @@ -15,8 +15,6 @@ #include #include "DisplayCMDs.h" - -#define display class Display{ protected: //how many chars are on current line