Skip to content

Commit

Permalink
add create char and fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursiveError committed Mar 14, 2023
1 parent f459b85 commit e14fbc0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/omnicrystal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,19 @@ Omnicrystal& Omnicrystal::display_off(){
/*------------------- FIM CONFIGURAÇÃO DO DISPLAY ---------------------*/

Omnicrystal& Omnicrystal::set_cursor(uint8_t line, uint8_t col){
if(line <= _line){
if(col <= _col){
if(line < _line){
if(col < _col){
send(addrs[line]+col, 0);
}
}
return *this;
}

Omnicrystal& Omnicrystal::create_char(uint8_t c[8], uint8_t pos){
pos &= 0b00000111;
send(0x40 | (pos<<3), 0);
for(size_t i = 0; i < 8; i++){
send(c[i], 1);
}
return *this;
}
4 changes: 3 additions & 1 deletion src/omnicrystal.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum LCDCharSize {

class Omnicrystal : public Print{
private:
static constexpr uint8_t addrs[4] = {0x80, 0xC0, 0x80+20, 0xC0+20}; //endereços para LCD 16x2 e 20x4
const uint8_t addrs[4] = {0x80, 0xC0, 0x80+20, 0xC0+20}; //endereços para LCD 16x2 e 20x4
LCDInterface &_bridge;
const BusType _bus; // tipo de comunicação 4 ou 8 bits
const uint8_t _line; // quantidade de linhas no display
Expand Down Expand Up @@ -97,6 +97,8 @@ class Omnicrystal : public Print{
Omnicrystal& display_off();
Omnicrystal& set_cursor(uint8_t line, uint8_t col);

Omnicrystal& create_char(uint8_t c[8], uint8_t pos);

Omnicrystal& begin();
virtual size_t write(uint8_t);
};
Expand Down

0 comments on commit e14fbc0

Please sign in to comment.