Display '\n' + Linux setup
This commit is contained in:
2
.clangd
Normal file
2
.clangd
Normal file
@@ -0,0 +1,2 @@
|
||||
CompileFlags:
|
||||
Remove: [-mlongcalls, -mtext-section-literals, -fipa-pta, -free]
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
.cache
|
||||
1316
compile_commands.json
Normal file
1316
compile_commands.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -12,8 +12,8 @@
|
||||
platform = espressif8266
|
||||
board = nodemcuv2
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
olikraus/U8g2@^2.36.15
|
||||
lib_deps = olikraus/U8g2@^2.36.15
|
||||
monitor_speed = 115200
|
||||
upload_speed = 921600
|
||||
debug_tool = esp-prog
|
||||
debug_port = COM3
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <Display.h>
|
||||
#include <algorithm>
|
||||
#include <Display/Display.h>
|
||||
#include <charconv>
|
||||
#include <string>
|
||||
|
||||
Display::Display(uint8_t clockPin, uint8_t dataPin)
|
||||
: u8g2(U8G2_R0, clockPin, dataPin, U8X8_PIN_NONE)
|
||||
@@ -45,6 +46,13 @@ void Display::splitText(const std::string text, std::vector<std::string> *out)
|
||||
uint8_t row = 0;
|
||||
for (uint i = 0; i < text.length(); i++)
|
||||
{
|
||||
if(text[i] == '\n')
|
||||
{
|
||||
row++;
|
||||
out->push_back("");
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string added = out->at(row) + text[i];
|
||||
if (u8g2.getStrWidth(added.c_str()) > u8g2.getWidth())
|
||||
{
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <Arduino.h>
|
||||
#include "pins_arduino.h"
|
||||
#include <Wire.h>
|
||||
#include <U8g2lib.h>
|
||||
#include <vector>
|
||||
@@ -10,7 +11,7 @@ private:
|
||||
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2;
|
||||
|
||||
public:
|
||||
Display(uint8_t clockPin = 12, uint8_t dataPin = 14);
|
||||
Display(uint8_t clockPin = D6, uint8_t dataPin = D5);
|
||||
virtual ~Display();
|
||||
|
||||
void init();
|
||||
@@ -1,7 +1,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <U8g2lib.h>
|
||||
#include <Display.h>
|
||||
#include <Display/Display.h>
|
||||
#include <string>
|
||||
|
||||
Display display;
|
||||
|
||||
@@ -13,6 +12,6 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
display.drawText("Das ist ein etwas längerer Test");
|
||||
display.drawText("Test\nTest2\nTest3");
|
||||
delay(1000);
|
||||
}
|
||||
Reference in New Issue
Block a user