lcd: simplify line printing
This commit is contained in:
parent
9492081fbb
commit
50b77d39f8
@ -6,7 +6,6 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
// commands
|
// commands
|
||||||
#define LCD_CLEARDISPLAY 0x01
|
#define LCD_CLEARDISPLAY 0x01
|
||||||
#define LCD_RETURNHOME 0x02
|
#define LCD_RETURNHOME 0x02
|
||||||
@ -75,6 +74,10 @@ public:
|
|||||||
void command (uint8_t);
|
void command (uint8_t);
|
||||||
void print (std::string const &s);
|
void print (std::string const &s);
|
||||||
void print (const char *s);
|
void print (const char *s);
|
||||||
|
void printOnLineOne (const char *s);
|
||||||
|
void printOnLineTwo (const char *s);
|
||||||
|
void printOnLineOne (std::string const &s);
|
||||||
|
void printOnLineTwo (std::string const &s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void send (uint8_t, uint8_t);
|
void send (uint8_t, uint8_t);
|
||||||
|
|||||||
@ -187,6 +187,31 @@ LiquidCrystal::print (const char *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LiquidCrystal::printOnLineOne (const char *s)
|
||||||
|
{
|
||||||
|
setCursor (0, 0);
|
||||||
|
print (s);
|
||||||
|
}
|
||||||
|
void
|
||||||
|
LiquidCrystal::printOnLineTwo (const char *s)
|
||||||
|
{
|
||||||
|
setCursor (0, 1);
|
||||||
|
print (s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LiquidCrystal::printOnLineOne (std::string const &s)
|
||||||
|
{
|
||||||
|
printOnLineOne (s.c_str ());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LiquidCrystal::printOnLineTwo (std::string const &s)
|
||||||
|
{
|
||||||
|
printOnLineTwo (s.c_str ());
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LiquidCrystal::setCursor (uint8_t col, uint8_t row)
|
LiquidCrystal::setCursor (uint8_t col, uint8_t row)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -59,10 +59,8 @@ StateHandler::displaySet (size_t mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_lcd->clear ();
|
_lcd->clear ();
|
||||||
_lcd->setCursor (0, 0);
|
_lcd->printOnLineOne (line_up);
|
||||||
_lcd->print (line_up);
|
_lcd->printOnLineTwo (line_down);
|
||||||
_lcd->setCursor (0, 1);
|
|
||||||
_lcd->print (line_down);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
|
|||||||
@ -36,8 +36,8 @@ main (void)
|
|||||||
DigitalIoPin d6 (1, 3, false, true, false);
|
DigitalIoPin d6 (1, 3, false, true, false);
|
||||||
DigitalIoPin d7 (0, 0, false, true, false);
|
DigitalIoPin d7 (0, 0, false, true, false);
|
||||||
LiquidCrystal lcd (&rs, &en, &d4, &d5, &d6, &d7);
|
LiquidCrystal lcd (&rs, &en, &d4, &d5, &d6, &d7);
|
||||||
lcd.setCursor (0, 0);
|
lcd.clear ();
|
||||||
lcd.print ("Vent-Machine");
|
lcd.printOnLineOne (" ESP-VENT_MAIN ");
|
||||||
|
|
||||||
/* Timers */
|
/* Timers */
|
||||||
Timer glob_time (ONE_K_HZ, true);
|
Timer glob_time (ONE_K_HZ, true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user