Skip to content

Commit

Permalink
suporte a comandos
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursiveError committed Mar 11, 2023
1 parent 2a6e25d commit ea7592e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/omnicrystal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,44 @@ size_t Omnicrystal::write(uint8_t data){
send(data, 1);
return 1;
}

/* ----------------- COMANDOS DO DISPLAY ---------------------*/
//envia comandos para o display
inline Omnicrystal& Omnicrystal::command(LCDCommand command){
send(command, 0); //0 indica RS em low, significa que vamos envar um comando
return *this; //apenas para encadeamento de metodos
}

Omnicrystal& Omnicrystal::clear(){
command(LCDClear);
delay(2); //clear e reset demoram 1.52ms para executar
return *this;
}

Omnicrystal& Omnicrystal::reset(){
command(LCDReset);
delay(2); //clear e reset demoram 1.52ms para executar
return *this;
}

inline Omnicrystal& Omnicrystal::move_cursor_left(){
command(LCDShiftCursotLeft);
return *this;
}

inline Omnicrystal& Omnicrystal::move_cursor_right(){
command(LCDShiftCursotRight);
return *this;
}

inline Omnicrystal& Omnicrystal::move_display_left(){
command(LCDShiftDisplayLeft);
return *this;
}

inline Omnicrystal& Omnicrystal::move_display_right(){
command(LCDShiftCursotRight);
return *this;
}

/* ----------------- FIM DOS COMANDOS DO DISPLAY ---------------------*/
23 changes: 23 additions & 0 deletions src/omnicrystal.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@

enum BusType {Bus4Bits, Bus8Bits};

//comandos do LCD
enum LCDCommand {
LCDClear = 0x01,
LCDReset = 0x02,
LCDShiftCursotLeft = 0x10,
LCDShiftCursotRight = 0x14,
LCDShiftDisplayLeft = 0x18,
LCDShiftDisplayRight = 0x1C,
};


class Omnicrystal : public Print{
private:
LCDInterface &_bridge;
Expand All @@ -23,6 +34,18 @@ class Omnicrystal : public Print{
public:
Omnicrystal(LCDInterface &bridge, const BusType bus, uint8_t line, uint8_t col) : _bridge{bridge}, _bus{bus},
_line{line}, _col{col}{}

//envia o codigo dos comandos
Omnicrystal& command(LCDCommand);
//funçoes para enviar cada um dos comandos
Omnicrystal& clear();
Omnicrystal& reset();
Omnicrystal& move_cursor_left();
Omnicrystal& move_cursor_right();
Omnicrystal& move_display_left();
Omnicrystal& move_display_right();


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

0 comments on commit ea7592e

Please sign in to comment.