[add] arm-linux cpp support

This commit is contained in:
wuhanstudio 2021-10-04 22:27:25 +01:00
parent 6b670120ed
commit 593b08662d
21 changed files with 22089 additions and 0 deletions

3
sys/arm-linux/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
bin/
obj/
*.o

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,22 @@
PI=pi@raspberrypi.local
SUBDIRS = $(wildcard u8g2*)
TARGET = subdirs
PHONY += $(TARGET) $(SUBDIRS) %.clean
all: $(TARGET)
subdirs: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
%.clean:
@(cd $(patsubst %.clean, %, $@) && $(MAKE) clean)
clean distclean: $(patsubst %, %.clean, $(SUBDIRS))
.PHONY: $(PHONY) install clean distclean
upload:
scp $(OUTDIR)/$(TARGET) $(PI):~/

View File

@ -0,0 +1,179 @@
# Chosse proper compiler for your PI
# NanoPi: arm-linux-gnueabi-gcc
# Raspberry Pi Zero: arm-linux-gnueabi-gcc
# Raspberry Pi 2: arm-linux-gnueabihf-gcc
# OrangePi Zero: arm-linux-gnueabihf-gcc
# NanoPi NEO: arm-linux-gnueabihf-gcc
# NanoPi NEO Plus 2: arm-linux-gnueabihf-gcc
# C-SKY Linux: csky-linux-gcc
CC=arm-linux-gnueabi-gcc
CXX=arm-linux-gnueabi-g++
# IP Address of your PI
PI=pi@raspberrypi.local
TARGET=u8g2_4wire_hw_spi_cpp
IDIR= -I ../../../drivers -I ../../../../../csrc -I ../../../port
CSRCDIR=../../../../../csrc
CXXSRCDIR=../../../port
OBJDIR=../../../obj
OUTDIR=../../../bin
LDIR= -L ../../../lib
LIBS= -lm
CFLAGS= $(IDIR) -W -Wall
OBJ+=u8g2_4wire_hw_spi.cpp.o\
../../../port/u8g2port.o\
../../../drivers/gpio.o\
../../../drivers/spi.o\
../../../drivers/i2c.o\
$(OBJDIR)/Print.cpp.o\
$(OBJDIR)/U8x8lib.cpp.o\
$(OBJDIR)/U8g2lib.cpp.o\
$(OBJDIR)/mui.o\
$(OBJDIR)/mui_u8g2.o\
$(OBJDIR)/u8g2_bitmap.o\
$(OBJDIR)/u8g2_box.o\
$(OBJDIR)/u8g2_buffer.o\
$(OBJDIR)/u8g2_button.o\
$(OBJDIR)/u8g2_circle.o\
$(OBJDIR)/u8g2_cleardisplay.o\
$(OBJDIR)/u8g2_d_memory.o\
$(OBJDIR)/u8g2_d_setup.o\
$(OBJDIR)/u8g2_font.o\
$(OBJDIR)/u8g2_fonts.o\
$(OBJDIR)/u8g2_hvline.o\
$(OBJDIR)/u8g2_input_value.o\
$(OBJDIR)/u8g2_intersection.o\
$(OBJDIR)/u8g2_kerning.o\
$(OBJDIR)/u8g2_line.o\
$(OBJDIR)/u8g2_ll_hvline.o\
$(OBJDIR)/u8g2_message.o\
$(OBJDIR)/u8g2_polygon.o\
$(OBJDIR)/u8g2_selection_list.o\
$(OBJDIR)/u8g2_setup.o\
$(OBJDIR)/u8log.o\
$(OBJDIR)/u8log_u8g2.o\
$(OBJDIR)/u8log_u8x8.o\
$(OBJDIR)/u8x8_8x8.o\
$(OBJDIR)/u8x8_byte.o\
$(OBJDIR)/u8x8_cad.o\
$(OBJDIR)/u8x8_capture.o\
$(OBJDIR)/u8x8_d_a2printer.o\
$(OBJDIR)/u8x8_debounce.o\
$(OBJDIR)/u8x8_d_gu800.o\
$(OBJDIR)/u8x8_d_hd44102.o\
$(OBJDIR)/u8x8_d_il3820_296x128.o\
$(OBJDIR)/u8x8_d_ist3020.o\
$(OBJDIR)/u8x8_d_ist7920.o\
$(OBJDIR)/u8x8_d_ks0108.o\
$(OBJDIR)/u8x8_d_lc7981.o\
$(OBJDIR)/u8x8_d_ld7032_60x32.o\
$(OBJDIR)/u8x8_d_ls013b7dh03.o\
$(OBJDIR)/u8x8_d_max7219.o\
$(OBJDIR)/u8x8_d_pcd8544_84x48.o\
$(OBJDIR)/u8x8_d_pcf8812.o\
$(OBJDIR)/u8x8_d_pcf8814_hx1230.o\
$(OBJDIR)/u8x8_d_s1d15721.o\
$(OBJDIR)/u8x8_d_s1d15e06.o\
$(OBJDIR)/u8x8_d_sbn1661.o\
$(OBJDIR)/u8x8_d_sed1330.o\
$(OBJDIR)/u8x8_d_sh1106_64x32.o\
$(OBJDIR)/u8x8_d_sh1106_72x40.o\
$(OBJDIR)/u8x8_d_sh1107.o\
$(OBJDIR)/u8x8_d_sh1108.o\
$(OBJDIR)/u8x8_d_sh1122.o\
$(OBJDIR)/u8x8_d_ssd1305.o\
$(OBJDIR)/u8x8_d_ssd1306_128x32.o\
$(OBJDIR)/u8x8_d_ssd1306_128x64_noname.o\
$(OBJDIR)/u8x8_d_ssd1306_2040x16.o\
$(OBJDIR)/u8x8_d_ssd1306_48x64.o\
$(OBJDIR)/u8x8_d_ssd1306_64x32.o\
$(OBJDIR)/u8x8_d_ssd1306_64x48.o\
$(OBJDIR)/u8x8_d_ssd1306_72x40.o\
$(OBJDIR)/u8x8_d_ssd1306_96x16.o\
$(OBJDIR)/u8x8_d_ssd1309.o\
$(OBJDIR)/u8x8_d_ssd1316.o\
$(OBJDIR)/u8x8_d_ssd1317.o\
$(OBJDIR)/u8x8_d_ssd1318.o\
$(OBJDIR)/u8x8_d_ssd1320.o\
$(OBJDIR)/u8x8_d_ssd1322.o\
$(OBJDIR)/u8x8_d_ssd1325.o\
$(OBJDIR)/u8x8_d_ssd1326.o\
$(OBJDIR)/u8x8_d_ssd1327.o\
$(OBJDIR)/u8x8_d_ssd1329.o\
$(OBJDIR)/u8x8_d_ssd1606_172x72.o\
$(OBJDIR)/u8x8_d_ssd1607_200x200.o\
$(OBJDIR)/u8x8_d_st7511.o\
$(OBJDIR)/u8x8_d_st75256.o\
$(OBJDIR)/u8x8_d_st7528.o\
$(OBJDIR)/u8x8_d_st75320.o\
$(OBJDIR)/u8x8_d_st7565.o\
$(OBJDIR)/u8x8_d_st7567.o\
$(OBJDIR)/u8x8_d_st7571.o\
$(OBJDIR)/u8x8_d_st7586s_erc240160.o\
$(OBJDIR)/u8x8_d_st7586s_s028hn118a.o\
$(OBJDIR)/u8x8_d_st7586s_ymc240160.o\
$(OBJDIR)/u8x8_d_st7588.o\
$(OBJDIR)/u8x8_d_st7920.o\
$(OBJDIR)/u8x8_d_stdio.o\
$(OBJDIR)/u8x8_d_t6963.o\
$(OBJDIR)/u8x8_d_uc1601.o\
$(OBJDIR)/u8x8_d_uc1604.o\
$(OBJDIR)/u8x8_d_uc1608.o\
$(OBJDIR)/u8x8_d_uc1609.o\
$(OBJDIR)/u8x8_d_uc1610.o\
$(OBJDIR)/u8x8_d_uc1611.o\
$(OBJDIR)/u8x8_d_uc1617.o\
$(OBJDIR)/u8x8_d_uc1638.o\
$(OBJDIR)/u8x8_d_uc1701_dogs102.o\
$(OBJDIR)/u8x8_d_uc1701_mini12864.o\
$(OBJDIR)/u8x8_debounce.o\
$(OBJDIR)/u8x8_display.o\
$(OBJDIR)/u8x8_fonts.o\
$(OBJDIR)/u8x8_gpio.o\
$(OBJDIR)/u8x8_input_value.o\
$(OBJDIR)/u8x8_message.o\
$(OBJDIR)/u8x8_selection_list.o\
$(OBJDIR)/u8x8_setup.o\
$(OBJDIR)/u8x8_string.o\
$(OBJDIR)/u8x8_u16toa.o\
$(OBJDIR)/u8x8_u8toa.o\
all: directories $(TARGET)
directories:
@mkdir -p $(OBJDIR)
@mkdir -p $(OUTDIR)
$(TARGET):$(OBJ)
@echo Generating $(TARGET) ...
@$(CXX) -o $(OUTDIR)/$@ $(OBJ) $(LDIR) $(LIBS)
u8g2_4wire_hw_spi.cpp.o: u8g2_4wire_hw_spi.cpp
$(CXX) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
$(OBJDIR)/%.cpp.o: $(CXXSRCDIR)/%.cpp
$(CXX) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
$(OBJDIR)/%.o: $(CSRCDIR)/%.c
$(CC) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
clean:
@echo RM -rf $(OBJDIR)/
@rm -rf $(OBJ)
@rm -rf $(OBJDIR)
@echo RM -rf $(OUTDIR)/
@rm -rf $(OUTDIR)
upload:
scp $(OUTDIR)/$(TARGET) $(PI):~/
run:
ssh $(PI)

View File

@ -0,0 +1,27 @@
#include <U8g2lib.h>
// By default, SPI bus /dev/spidev0.0 is used, as defined in port/U8g2lib.h
#define OLED_SPI_PIN_RES 25
#define OLED_SPI_PIN_DC 24
// CS pin is controlled by linux spi driver
#define OLED_SPI_PIN_CS 8
// Check https://github.com/olikraus/u8g2/wiki/u8g2setupcpp for all supported devices
static U8G2_SSD1306_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0,
/* cs=*/ OLED_SPI_PIN_CS,
/* dc=*/ OLED_SPI_PIN_DC,
/* reset=*/ OLED_SPI_PIN_RES);
// same as the NONAME variant, but may solve the "every 2nd line skipped" problem
int main()
{
u8g2.begin();
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_6x13_tr); // choose a suitable font
u8g2.drawStr(1, 18, "U8g2 on HW SPI"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
u8g2.setFont(u8g2_font_unifont_t_symbols);
u8g2.drawGlyph(112, 56, 0x2603 );
u8g2.sendBuffer();
}

View File

@ -0,0 +1,179 @@
# Chosse proper compiler for your PI
# NanoPi: arm-linux-gnueabi-gcc
# Raspberry Pi Zero: arm-linux-gnueabi-gcc
# Raspberry Pi 2: arm-linux-gnueabihf-gcc
# OrangePi Zero: arm-linux-gnueabihf-gcc
# NanoPi NEO: arm-linux-gnueabihf-gcc
# NanoPi NEO Plus 2: arm-linux-gnueabihf-gcc
# C-SKY Linux: csky-linux-gcc
CC=arm-linux-gnueabi-gcc
CXX=arm-linux-gnueabi-g++
# IP Address of your PI
PI=pi@raspberrypi.local
TARGET=u8g2_4wire_sw_spi_cpp
IDIR= -I ../../../drivers -I ../../../../../csrc -I ../../../port
CSRCDIR=../../../../../csrc
CXXSRCDIR=../../../port
OBJDIR=../../../obj
OUTDIR=../../../bin
LDIR= -L ../../../lib
LIBS= -lm
CFLAGS= $(IDIR) -W -Wall
OBJ+=u8g2_4wire_sw_spi.cpp.o\
../../../port/u8g2port.o\
../../../drivers/gpio.o\
../../../drivers/spi.o\
../../../drivers/i2c.o\
$(OBJDIR)/Print.cpp.o\
$(OBJDIR)/U8x8lib.cpp.o\
$(OBJDIR)/U8g2lib.cpp.o\
$(OBJDIR)/mui.o\
$(OBJDIR)/mui_u8g2.o\
$(OBJDIR)/u8g2_bitmap.o\
$(OBJDIR)/u8g2_box.o\
$(OBJDIR)/u8g2_buffer.o\
$(OBJDIR)/u8g2_button.o\
$(OBJDIR)/u8g2_circle.o\
$(OBJDIR)/u8g2_cleardisplay.o\
$(OBJDIR)/u8g2_d_memory.o\
$(OBJDIR)/u8g2_d_setup.o\
$(OBJDIR)/u8g2_font.o\
$(OBJDIR)/u8g2_fonts.o\
$(OBJDIR)/u8g2_hvline.o\
$(OBJDIR)/u8g2_input_value.o\
$(OBJDIR)/u8g2_intersection.o\
$(OBJDIR)/u8g2_kerning.o\
$(OBJDIR)/u8g2_line.o\
$(OBJDIR)/u8g2_ll_hvline.o\
$(OBJDIR)/u8g2_message.o\
$(OBJDIR)/u8g2_polygon.o\
$(OBJDIR)/u8g2_selection_list.o\
$(OBJDIR)/u8g2_setup.o\
$(OBJDIR)/u8log.o\
$(OBJDIR)/u8log_u8g2.o\
$(OBJDIR)/u8log_u8x8.o\
$(OBJDIR)/u8x8_8x8.o\
$(OBJDIR)/u8x8_byte.o\
$(OBJDIR)/u8x8_cad.o\
$(OBJDIR)/u8x8_capture.o\
$(OBJDIR)/u8x8_d_a2printer.o\
$(OBJDIR)/u8x8_debounce.o\
$(OBJDIR)/u8x8_d_gu800.o\
$(OBJDIR)/u8x8_d_hd44102.o\
$(OBJDIR)/u8x8_d_il3820_296x128.o\
$(OBJDIR)/u8x8_d_ist3020.o\
$(OBJDIR)/u8x8_d_ist7920.o\
$(OBJDIR)/u8x8_d_ks0108.o\
$(OBJDIR)/u8x8_d_lc7981.o\
$(OBJDIR)/u8x8_d_ld7032_60x32.o\
$(OBJDIR)/u8x8_d_ls013b7dh03.o\
$(OBJDIR)/u8x8_d_max7219.o\
$(OBJDIR)/u8x8_d_pcd8544_84x48.o\
$(OBJDIR)/u8x8_d_pcf8812.o\
$(OBJDIR)/u8x8_d_pcf8814_hx1230.o\
$(OBJDIR)/u8x8_d_s1d15721.o\
$(OBJDIR)/u8x8_d_s1d15e06.o\
$(OBJDIR)/u8x8_d_sbn1661.o\
$(OBJDIR)/u8x8_d_sed1330.o\
$(OBJDIR)/u8x8_d_sh1106_64x32.o\
$(OBJDIR)/u8x8_d_sh1106_72x40.o\
$(OBJDIR)/u8x8_d_sh1107.o\
$(OBJDIR)/u8x8_d_sh1108.o\
$(OBJDIR)/u8x8_d_sh1122.o\
$(OBJDIR)/u8x8_d_ssd1305.o\
$(OBJDIR)/u8x8_d_ssd1306_128x32.o\
$(OBJDIR)/u8x8_d_ssd1306_128x64_noname.o\
$(OBJDIR)/u8x8_d_ssd1306_2040x16.o\
$(OBJDIR)/u8x8_d_ssd1306_48x64.o\
$(OBJDIR)/u8x8_d_ssd1306_64x32.o\
$(OBJDIR)/u8x8_d_ssd1306_64x48.o\
$(OBJDIR)/u8x8_d_ssd1306_72x40.o\
$(OBJDIR)/u8x8_d_ssd1306_96x16.o\
$(OBJDIR)/u8x8_d_ssd1309.o\
$(OBJDIR)/u8x8_d_ssd1316.o\
$(OBJDIR)/u8x8_d_ssd1317.o\
$(OBJDIR)/u8x8_d_ssd1318.o\
$(OBJDIR)/u8x8_d_ssd1320.o\
$(OBJDIR)/u8x8_d_ssd1322.o\
$(OBJDIR)/u8x8_d_ssd1325.o\
$(OBJDIR)/u8x8_d_ssd1326.o\
$(OBJDIR)/u8x8_d_ssd1327.o\
$(OBJDIR)/u8x8_d_ssd1329.o\
$(OBJDIR)/u8x8_d_ssd1606_172x72.o\
$(OBJDIR)/u8x8_d_ssd1607_200x200.o\
$(OBJDIR)/u8x8_d_st7511.o\
$(OBJDIR)/u8x8_d_st75256.o\
$(OBJDIR)/u8x8_d_st7528.o\
$(OBJDIR)/u8x8_d_st75320.o\
$(OBJDIR)/u8x8_d_st7565.o\
$(OBJDIR)/u8x8_d_st7567.o\
$(OBJDIR)/u8x8_d_st7571.o\
$(OBJDIR)/u8x8_d_st7586s_erc240160.o\
$(OBJDIR)/u8x8_d_st7586s_s028hn118a.o\
$(OBJDIR)/u8x8_d_st7586s_ymc240160.o\
$(OBJDIR)/u8x8_d_st7588.o\
$(OBJDIR)/u8x8_d_st7920.o\
$(OBJDIR)/u8x8_d_stdio.o\
$(OBJDIR)/u8x8_d_t6963.o\
$(OBJDIR)/u8x8_d_uc1601.o\
$(OBJDIR)/u8x8_d_uc1604.o\
$(OBJDIR)/u8x8_d_uc1608.o\
$(OBJDIR)/u8x8_d_uc1609.o\
$(OBJDIR)/u8x8_d_uc1610.o\
$(OBJDIR)/u8x8_d_uc1611.o\
$(OBJDIR)/u8x8_d_uc1617.o\
$(OBJDIR)/u8x8_d_uc1638.o\
$(OBJDIR)/u8x8_d_uc1701_dogs102.o\
$(OBJDIR)/u8x8_d_uc1701_mini12864.o\
$(OBJDIR)/u8x8_debounce.o\
$(OBJDIR)/u8x8_display.o\
$(OBJDIR)/u8x8_fonts.o\
$(OBJDIR)/u8x8_gpio.o\
$(OBJDIR)/u8x8_input_value.o\
$(OBJDIR)/u8x8_message.o\
$(OBJDIR)/u8x8_selection_list.o\
$(OBJDIR)/u8x8_setup.o\
$(OBJDIR)/u8x8_string.o\
$(OBJDIR)/u8x8_u16toa.o\
$(OBJDIR)/u8x8_u8toa.o\
all: directories $(TARGET)
directories:
@mkdir -p $(OBJDIR)
@mkdir -p $(OUTDIR)
$(TARGET):$(OBJ)
@echo Generating $(TARGET) ...
@$(CXX) -o $(OUTDIR)/$@ $(OBJ) $(LDIR) $(LIBS)
u8g2_4wire_sw_spi.cpp.o: u8g2_4wire_sw_spi.cpp
$(CXX) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
$(OBJDIR)/%.cpp.o: $(CXXSRCDIR)/%.cpp
$(CXX) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
$(OBJDIR)/%.o: $(CSRCDIR)/%.c
$(CC) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
clean:
@echo RM -rf $(OBJDIR)/
@rm -rf $(OBJ)
@rm -rf $(OBJDIR)
@echo RM -rf $(OUTDIR)/
@rm -rf $(OUTDIR)
upload:
scp $(OUTDIR)/$(TARGET) $(PI):~/
run:
ssh $(PI)

View File

@ -0,0 +1,29 @@
#include <U8g2lib.h>
#define OLED_SPI_PIN_MOSI 13
#define OLED_SPI_PIN_SCK 26
// Use a different pin here rather than default SPI pins, which may cause issue
#define OLED_SPI_PIN_RES 25
#define OLED_SPI_PIN_DC 24
#define OLED_SPI_PIN_CS 23
// Check https://github.com/olikraus/u8g2/wiki/u8g2setupcpp for all supported devices
static U8G2_SSD1306_128X64_NONAME_F_4W_SW_SPI u8g2(U8G2_R0,\
/* clock=*/ OLED_SPI_PIN_SCK,\
/* data=*/ OLED_SPI_PIN_MOSI,\
/* cs=*/ OLED_SPI_PIN_CS,\
/* dc=*/ OLED_SPI_PIN_DC,\
/* reset=*/ OLED_SPI_PIN_RES);
int main()
{
u8g2.begin();
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_6x13_tr); // choose a suitable font
u8g2.drawStr(1, 18, "U8g2 on SW SPI"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
u8g2.setFont(u8g2_font_unifont_t_symbols);
u8g2.drawGlyph(112, 56, 0x2603 );
u8g2.sendBuffer();
}

View File

@ -0,0 +1,179 @@
# Chosse proper compiler for your PI
# NanoPi: arm-linux-gnueabi-gcc
# Raspberry Pi Zero: arm-linux-gnueabi-gcc
# Raspberry Pi 2: arm-linux-gnueabihf-gcc
# OrangePi Zero: arm-linux-gnueabihf-gcc
# NanoPi NEO: arm-linux-gnueabihf-gcc
# NanoPi NEO Plus 2: arm-linux-gnueabihf-gcc
# C-SKY Linux: csky-linux-gcc
CC=arm-linux-gnueabi-gcc
CXX=arm-linux-gnueabi-g++
# IP Address of your PI
PI=pi@raspberrypi.local
TARGET=u8g2_hw_i2c_cpp
IDIR= -I ../../../drivers -I ../../../../../csrc -I ../../../port
CSRCDIR=../../../../../csrc
CXXSRCDIR=../../../port
OBJDIR=../../../obj
OUTDIR=../../../bin
LDIR= -L ../../../lib
LIBS= -lm
CFLAGS= $(IDIR) -W -Wall
OBJ+=u8g2_hw_i2c.cpp.o\
../../../port/u8g2port.o\
../../../drivers/gpio.o\
../../../drivers/spi.o\
../../../drivers/i2c.o\
$(OBJDIR)/Print.cpp.o\
$(OBJDIR)/U8x8lib.cpp.o\
$(OBJDIR)/U8g2lib.cpp.o\
$(OBJDIR)/mui.o\
$(OBJDIR)/mui_u8g2.o\
$(OBJDIR)/u8g2_bitmap.o\
$(OBJDIR)/u8g2_box.o\
$(OBJDIR)/u8g2_buffer.o\
$(OBJDIR)/u8g2_button.o\
$(OBJDIR)/u8g2_circle.o\
$(OBJDIR)/u8g2_cleardisplay.o\
$(OBJDIR)/u8g2_d_memory.o\
$(OBJDIR)/u8g2_d_setup.o\
$(OBJDIR)/u8g2_font.o\
$(OBJDIR)/u8g2_fonts.o\
$(OBJDIR)/u8g2_hvline.o\
$(OBJDIR)/u8g2_input_value.o\
$(OBJDIR)/u8g2_intersection.o\
$(OBJDIR)/u8g2_kerning.o\
$(OBJDIR)/u8g2_line.o\
$(OBJDIR)/u8g2_ll_hvline.o\
$(OBJDIR)/u8g2_message.o\
$(OBJDIR)/u8g2_polygon.o\
$(OBJDIR)/u8g2_selection_list.o\
$(OBJDIR)/u8g2_setup.o\
$(OBJDIR)/u8log.o\
$(OBJDIR)/u8log_u8g2.o\
$(OBJDIR)/u8log_u8x8.o\
$(OBJDIR)/u8x8_8x8.o\
$(OBJDIR)/u8x8_byte.o\
$(OBJDIR)/u8x8_cad.o\
$(OBJDIR)/u8x8_capture.o\
$(OBJDIR)/u8x8_d_a2printer.o\
$(OBJDIR)/u8x8_debounce.o\
$(OBJDIR)/u8x8_d_gu800.o\
$(OBJDIR)/u8x8_d_hd44102.o\
$(OBJDIR)/u8x8_d_il3820_296x128.o\
$(OBJDIR)/u8x8_d_ist3020.o\
$(OBJDIR)/u8x8_d_ist7920.o\
$(OBJDIR)/u8x8_d_ks0108.o\
$(OBJDIR)/u8x8_d_lc7981.o\
$(OBJDIR)/u8x8_d_ld7032_60x32.o\
$(OBJDIR)/u8x8_d_ls013b7dh03.o\
$(OBJDIR)/u8x8_d_max7219.o\
$(OBJDIR)/u8x8_d_pcd8544_84x48.o\
$(OBJDIR)/u8x8_d_pcf8812.o\
$(OBJDIR)/u8x8_d_pcf8814_hx1230.o\
$(OBJDIR)/u8x8_d_s1d15721.o\
$(OBJDIR)/u8x8_d_s1d15e06.o\
$(OBJDIR)/u8x8_d_sbn1661.o\
$(OBJDIR)/u8x8_d_sed1330.o\
$(OBJDIR)/u8x8_d_sh1106_64x32.o\
$(OBJDIR)/u8x8_d_sh1106_72x40.o\
$(OBJDIR)/u8x8_d_sh1107.o\
$(OBJDIR)/u8x8_d_sh1108.o\
$(OBJDIR)/u8x8_d_sh1122.o\
$(OBJDIR)/u8x8_d_ssd1305.o\
$(OBJDIR)/u8x8_d_ssd1306_128x32.o\
$(OBJDIR)/u8x8_d_ssd1306_128x64_noname.o\
$(OBJDIR)/u8x8_d_ssd1306_2040x16.o\
$(OBJDIR)/u8x8_d_ssd1306_48x64.o\
$(OBJDIR)/u8x8_d_ssd1306_64x32.o\
$(OBJDIR)/u8x8_d_ssd1306_64x48.o\
$(OBJDIR)/u8x8_d_ssd1306_72x40.o\
$(OBJDIR)/u8x8_d_ssd1306_96x16.o\
$(OBJDIR)/u8x8_d_ssd1309.o\
$(OBJDIR)/u8x8_d_ssd1316.o\
$(OBJDIR)/u8x8_d_ssd1317.o\
$(OBJDIR)/u8x8_d_ssd1318.o\
$(OBJDIR)/u8x8_d_ssd1320.o\
$(OBJDIR)/u8x8_d_ssd1322.o\
$(OBJDIR)/u8x8_d_ssd1325.o\
$(OBJDIR)/u8x8_d_ssd1326.o\
$(OBJDIR)/u8x8_d_ssd1327.o\
$(OBJDIR)/u8x8_d_ssd1329.o\
$(OBJDIR)/u8x8_d_ssd1606_172x72.o\
$(OBJDIR)/u8x8_d_ssd1607_200x200.o\
$(OBJDIR)/u8x8_d_st7511.o\
$(OBJDIR)/u8x8_d_st75256.o\
$(OBJDIR)/u8x8_d_st7528.o\
$(OBJDIR)/u8x8_d_st75320.o\
$(OBJDIR)/u8x8_d_st7565.o\
$(OBJDIR)/u8x8_d_st7567.o\
$(OBJDIR)/u8x8_d_st7571.o\
$(OBJDIR)/u8x8_d_st7586s_erc240160.o\
$(OBJDIR)/u8x8_d_st7586s_s028hn118a.o\
$(OBJDIR)/u8x8_d_st7586s_ymc240160.o\
$(OBJDIR)/u8x8_d_st7588.o\
$(OBJDIR)/u8x8_d_st7920.o\
$(OBJDIR)/u8x8_d_stdio.o\
$(OBJDIR)/u8x8_d_t6963.o\
$(OBJDIR)/u8x8_d_uc1601.o\
$(OBJDIR)/u8x8_d_uc1604.o\
$(OBJDIR)/u8x8_d_uc1608.o\
$(OBJDIR)/u8x8_d_uc1609.o\
$(OBJDIR)/u8x8_d_uc1610.o\
$(OBJDIR)/u8x8_d_uc1611.o\
$(OBJDIR)/u8x8_d_uc1617.o\
$(OBJDIR)/u8x8_d_uc1638.o\
$(OBJDIR)/u8x8_d_uc1701_dogs102.o\
$(OBJDIR)/u8x8_d_uc1701_mini12864.o\
$(OBJDIR)/u8x8_debounce.o\
$(OBJDIR)/u8x8_display.o\
$(OBJDIR)/u8x8_fonts.o\
$(OBJDIR)/u8x8_gpio.o\
$(OBJDIR)/u8x8_input_value.o\
$(OBJDIR)/u8x8_message.o\
$(OBJDIR)/u8x8_selection_list.o\
$(OBJDIR)/u8x8_setup.o\
$(OBJDIR)/u8x8_string.o\
$(OBJDIR)/u8x8_u16toa.o\
$(OBJDIR)/u8x8_u8toa.o\
all: directories $(TARGET)
directories:
@mkdir -p $(OBJDIR)
@mkdir -p $(OUTDIR)
$(TARGET):$(OBJ)
@echo Generating $(TARGET) ...
@$(CXX) -o $(OUTDIR)/$@ $(OBJ) $(LDIR) $(LIBS)
u8g2_hw_i2c.cpp.o: u8g2_hw_i2c.cpp
$(CXX) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
$(OBJDIR)/%.cpp.o: $(CXXSRCDIR)/%.cpp
$(CXX) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
$(OBJDIR)/%.o: $(CSRCDIR)/%.c
$(CC) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
clean:
@echo RM -rf $(OBJDIR)/
@rm -rf $(OBJ)
@rm -rf $(OBJDIR)
@echo RM -rf $(OUTDIR)/
@rm -rf $(OUTDIR)
upload:
scp $(OUTDIR)/$(TARGET) $(PI):~/
run:
ssh $(PI)

View File

@ -0,0 +1,16 @@
#include <U8g2lib.h>
// Check https://github.com/olikraus/u8g2/wiki/u8g2setupcpp for all supported devices
static U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
int main(void)
{
u8g2.begin();
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_6x13_tr); // choose a suitable font
u8g2.drawStr(1, 18, "U8g2 on HW I2C"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
u8g2.setFont(u8g2_font_unifont_t_symbols);
u8g2.drawGlyph(112, 56, 0x2603 );
u8g2.sendBuffer();
}

View File

@ -0,0 +1,179 @@
# Chosse proper compiler for your PI
# NanoPi: arm-linux-gnueabi-gcc
# Raspberry Pi Zero: arm-linux-gnueabi-gcc
# Raspberry Pi 2: arm-linux-gnueabihf-gcc
# OrangePi Zero: arm-linux-gnueabihf-gcc
# NanoPi NEO: arm-linux-gnueabihf-gcc
# NanoPi NEO Plus 2: arm-linux-gnueabihf-gcc
# C-SKY Linux: csky-linux-gcc
CC=arm-linux-gnueabi-gcc
CXX=arm-linux-gnueabi-g++
# IP Address of your PI
PI=pi@raspberrypi.local
TARGET=u8g2_sw_i2c_cpp
IDIR= -I ../../../drivers -I ../../../../../csrc -I ../../../port
CSRCDIR=../../../../../csrc
CXXSRCDIR=../../../port
OBJDIR=../../../obj
OUTDIR=../../../bin
LDIR= -L ../../../lib
LIBS= -lm
CFLAGS= $(IDIR) -W -Wall
OBJ+=u8g2_sw_i2c.cpp.o\
../../../port/u8g2port.o\
../../../drivers/gpio.o\
../../../drivers/spi.o\
../../../drivers/i2c.o\
$(OBJDIR)/Print.cpp.o\
$(OBJDIR)/U8x8lib.cpp.o\
$(OBJDIR)/U8g2lib.cpp.o\
$(OBJDIR)/mui.o\
$(OBJDIR)/mui_u8g2.o\
$(OBJDIR)/u8g2_bitmap.o\
$(OBJDIR)/u8g2_box.o\
$(OBJDIR)/u8g2_buffer.o\
$(OBJDIR)/u8g2_button.o\
$(OBJDIR)/u8g2_circle.o\
$(OBJDIR)/u8g2_cleardisplay.o\
$(OBJDIR)/u8g2_d_memory.o\
$(OBJDIR)/u8g2_d_setup.o\
$(OBJDIR)/u8g2_font.o\
$(OBJDIR)/u8g2_fonts.o\
$(OBJDIR)/u8g2_hvline.o\
$(OBJDIR)/u8g2_input_value.o\
$(OBJDIR)/u8g2_intersection.o\
$(OBJDIR)/u8g2_kerning.o\
$(OBJDIR)/u8g2_line.o\
$(OBJDIR)/u8g2_ll_hvline.o\
$(OBJDIR)/u8g2_message.o\
$(OBJDIR)/u8g2_polygon.o\
$(OBJDIR)/u8g2_selection_list.o\
$(OBJDIR)/u8g2_setup.o\
$(OBJDIR)/u8log.o\
$(OBJDIR)/u8log_u8g2.o\
$(OBJDIR)/u8log_u8x8.o\
$(OBJDIR)/u8x8_8x8.o\
$(OBJDIR)/u8x8_byte.o\
$(OBJDIR)/u8x8_cad.o\
$(OBJDIR)/u8x8_capture.o\
$(OBJDIR)/u8x8_d_a2printer.o\
$(OBJDIR)/u8x8_debounce.o\
$(OBJDIR)/u8x8_d_gu800.o\
$(OBJDIR)/u8x8_d_hd44102.o\
$(OBJDIR)/u8x8_d_il3820_296x128.o\
$(OBJDIR)/u8x8_d_ist3020.o\
$(OBJDIR)/u8x8_d_ist7920.o\
$(OBJDIR)/u8x8_d_ks0108.o\
$(OBJDIR)/u8x8_d_lc7981.o\
$(OBJDIR)/u8x8_d_ld7032_60x32.o\
$(OBJDIR)/u8x8_d_ls013b7dh03.o\
$(OBJDIR)/u8x8_d_max7219.o\
$(OBJDIR)/u8x8_d_pcd8544_84x48.o\
$(OBJDIR)/u8x8_d_pcf8812.o\
$(OBJDIR)/u8x8_d_pcf8814_hx1230.o\
$(OBJDIR)/u8x8_d_s1d15721.o\
$(OBJDIR)/u8x8_d_s1d15e06.o\
$(OBJDIR)/u8x8_d_sbn1661.o\
$(OBJDIR)/u8x8_d_sed1330.o\
$(OBJDIR)/u8x8_d_sh1106_64x32.o\
$(OBJDIR)/u8x8_d_sh1106_72x40.o\
$(OBJDIR)/u8x8_d_sh1107.o\
$(OBJDIR)/u8x8_d_sh1108.o\
$(OBJDIR)/u8x8_d_sh1122.o\
$(OBJDIR)/u8x8_d_ssd1305.o\
$(OBJDIR)/u8x8_d_ssd1306_128x32.o\
$(OBJDIR)/u8x8_d_ssd1306_128x64_noname.o\
$(OBJDIR)/u8x8_d_ssd1306_2040x16.o\
$(OBJDIR)/u8x8_d_ssd1306_48x64.o\
$(OBJDIR)/u8x8_d_ssd1306_64x32.o\
$(OBJDIR)/u8x8_d_ssd1306_64x48.o\
$(OBJDIR)/u8x8_d_ssd1306_72x40.o\
$(OBJDIR)/u8x8_d_ssd1306_96x16.o\
$(OBJDIR)/u8x8_d_ssd1309.o\
$(OBJDIR)/u8x8_d_ssd1316.o\
$(OBJDIR)/u8x8_d_ssd1317.o\
$(OBJDIR)/u8x8_d_ssd1318.o\
$(OBJDIR)/u8x8_d_ssd1320.o\
$(OBJDIR)/u8x8_d_ssd1322.o\
$(OBJDIR)/u8x8_d_ssd1325.o\
$(OBJDIR)/u8x8_d_ssd1326.o\
$(OBJDIR)/u8x8_d_ssd1327.o\
$(OBJDIR)/u8x8_d_ssd1329.o\
$(OBJDIR)/u8x8_d_ssd1606_172x72.o\
$(OBJDIR)/u8x8_d_ssd1607_200x200.o\
$(OBJDIR)/u8x8_d_st7511.o\
$(OBJDIR)/u8x8_d_st75256.o\
$(OBJDIR)/u8x8_d_st7528.o\
$(OBJDIR)/u8x8_d_st75320.o\
$(OBJDIR)/u8x8_d_st7565.o\
$(OBJDIR)/u8x8_d_st7567.o\
$(OBJDIR)/u8x8_d_st7571.o\
$(OBJDIR)/u8x8_d_st7586s_erc240160.o\
$(OBJDIR)/u8x8_d_st7586s_s028hn118a.o\
$(OBJDIR)/u8x8_d_st7586s_ymc240160.o\
$(OBJDIR)/u8x8_d_st7588.o\
$(OBJDIR)/u8x8_d_st7920.o\
$(OBJDIR)/u8x8_d_stdio.o\
$(OBJDIR)/u8x8_d_t6963.o\
$(OBJDIR)/u8x8_d_uc1601.o\
$(OBJDIR)/u8x8_d_uc1604.o\
$(OBJDIR)/u8x8_d_uc1608.o\
$(OBJDIR)/u8x8_d_uc1609.o\
$(OBJDIR)/u8x8_d_uc1610.o\
$(OBJDIR)/u8x8_d_uc1611.o\
$(OBJDIR)/u8x8_d_uc1617.o\
$(OBJDIR)/u8x8_d_uc1638.o\
$(OBJDIR)/u8x8_d_uc1701_dogs102.o\
$(OBJDIR)/u8x8_d_uc1701_mini12864.o\
$(OBJDIR)/u8x8_debounce.o\
$(OBJDIR)/u8x8_display.o\
$(OBJDIR)/u8x8_fonts.o\
$(OBJDIR)/u8x8_gpio.o\
$(OBJDIR)/u8x8_input_value.o\
$(OBJDIR)/u8x8_message.o\
$(OBJDIR)/u8x8_selection_list.o\
$(OBJDIR)/u8x8_setup.o\
$(OBJDIR)/u8x8_string.o\
$(OBJDIR)/u8x8_u16toa.o\
$(OBJDIR)/u8x8_u8toa.o\
all: directories $(TARGET)
directories:
@mkdir -p $(OBJDIR)
@mkdir -p $(OUTDIR)
$(TARGET):$(OBJ)
@echo Generating $(TARGET) ...
@$(CXX) -o $(OUTDIR)/$@ $(OBJ) $(LDIR) $(LIBS)
u8g2_sw_i2c.cpp.o: u8g2_sw_i2c.cpp
$(CXX) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
$(OBJDIR)/%.cpp.o: $(CXXSRCDIR)/%.cpp
$(CXX) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
$(OBJDIR)/%.o: $(CSRCDIR)/%.c
$(CC) -c -o $@ $< $(CFLAGS) $(LDIR) $(LIBS)
clean:
@echo RM -rf $(OBJDIR)/
@rm -rf $(OBJ)
@rm -rf $(OBJDIR)
@echo RM -rf $(OUTDIR)/
@rm -rf $(OUTDIR)
upload:
scp $(OUTDIR)/$(TARGET) $(PI):~/
run:
ssh $(PI)

View File

@ -0,0 +1,23 @@
#include <U8g2lib.h>
#define OLED_I2C_PIN_SCL 20
#define OLED_I2C_PIN_SDA 21
// Check https://github.com/olikraus/u8g2/wiki/u8g2setupcpp for all supported devices
static U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0,
/* clock=*/ OLED_I2C_PIN_SCL,
/* data=*/ OLED_I2C_PIN_SDA,
/* reset=*/ U8X8_PIN_NONE);
// All Boards without Reset of the Display
int main(void)
{
u8g2.begin();
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_6x13_tr); // choose a suitable font
u8g2.drawStr(1, 18, "U8g2 on SW I2C"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
u8g2.setFont(u8g2_font_unifont_t_symbols);
u8g2.drawGlyph(112, 56, 0x2603 );
u8g2.sendBuffer();
}

View File

@ -0,0 +1,234 @@
/*
Print.cpp - Base class that provides print() and println()
Copyright (c) 2008 David A. Mellis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified 23 November 2006 by David A. Mellis
Modified 03 August 2015 by Chuck Todd
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
// Use Self-defined isnan isinf in Print.h
//#include <math.h>
#include "Print.h"
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size)
{
size_t n = 0;
while (size--) {
if (write(*buffer++)) n++;
else break;
}
return n;
}
size_t Print::print(const char str[])
{
return write(str);
}
size_t Print::print(char c)
{
return write(c);
}
size_t Print::print(unsigned char b, int base)
{
return print((unsigned long) b, base);
}
size_t Print::print(int n, int base)
{
return print((long) n, base);
}
size_t Print::print(unsigned int n, int base)
{
return print((unsigned long) n, base);
}
size_t Print::print(long n, int base)
{
if (base == 0) {
return write(n);
} else if (base == 10) {
if (n < 0) {
int t = print('-');
n = -n;
return printNumber(n, 10) + t;
}
return printNumber(n, 10);
} else {
return printNumber(n, base);
}
}
size_t Print::print(unsigned long n, int base)
{
if (base == 0) return write(n);
else return printNumber(n, base);
}
size_t Print::print(double n, int digits)
{
return printFloat(n, digits);
}
size_t Print::print(const Printable& x)
{
return x.printTo(*this);
}
size_t Print::println(void)
{
return write("\r\n");
}
size_t Print::println(const char c[])
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(char c)
{
size_t n = print(c);
n += println();
return n;
}
size_t Print::println(unsigned char b, int base)
{
size_t n = print(b, base);
n += println();
return n;
}
size_t Print::println(int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned int num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(unsigned long num, int base)
{
size_t n = print(num, base);
n += println();
return n;
}
size_t Print::println(double num, int digits)
{
size_t n = print(num, digits);
n += println();
return n;
}
size_t Print::println(const Printable& x)
{
size_t n = print(x);
n += println();
return n;
}
// Private Methods /////////////////////////////////////////////////////////////
size_t Print::printNumber(unsigned long n, uint8_t base)
{
char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
char *str = &buf[sizeof(buf) - 1];
*str = '\0';
// prevent crash if called with base == 1
if (base < 2) base = 10;
do {
char c = n % base;
n /= base;
*--str = c < 10 ? c + '0' : c + 'A' - 10;
} while(n);
return write(str);
}
size_t Print::printFloat(double number, uint8_t digits)
{
size_t n = 0;
if (isnan(number)) return print("nan");
if (isinf(number)) return print("inf");
if (number > 4294967040.0) return print ("ovf"); // constant determined empirically
if (number <-4294967040.0) return print ("ovf"); // constant determined empirically
// Handle negative numbers
if (number < 0.0)
{
n += print('-');
number = -number;
}
// Round correctly so that print(1.999, 2) prints as "2.00"
double rounding = 0.5;
for (uint8_t i=0; i<digits; ++i)
rounding /= 10.0;
number += rounding;
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
n += print(int_part);
// Print the decimal point, but only if there are digits beyond
if (digits > 0) {
n += print('.');
}
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
unsigned int toPrint = (unsigned int)(remainder);
n += print(toPrint);
remainder -= toPrint;
}
return n;
}

View File

@ -0,0 +1,94 @@
/*
Print.h - Base class that provides print() and println()
Copyright (c) 2008 David A. Mellis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef Print_h
#define Print_h
#include <inttypes.h>
#include <stdio.h> // for size_t
#include <string.h>
#include "Printable.h"
#define DEC 10
#define HEX 16
#define OCT 8
#ifdef BIN // Prevent warnings if BIN is previously defined in "iotnx4.h" or similar
#undef BIN
#endif
#define BIN 2
class Print
{
private:
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printFloat(double, uint8_t);
int isnan(double x) { return x != x; };
int isinf(double x) { return !isnan(x) && isnan(x - x); };
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Print() : write_error(0) {}
int getWriteError() { return write_error; }
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
size_t write(const char *str) {
if (str == NULL) return 0;
return write((const uint8_t *)str, strlen(str));
}
virtual size_t write(const uint8_t *buffer, size_t size);
size_t write(const char *buffer, size_t size) {
return write((const uint8_t *)buffer, size);
}
// default to zero, meaning "a single write may block"
// should be overriden by subclasses with buffering
virtual int availableForWrite() { return 0; }
// size_t print(const __FlashStringHelper *);
// size_t print(const String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
size_t print(int, int = DEC);
size_t print(unsigned int, int = DEC);
size_t print(long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(double, int = 2);
size_t print(const Printable&);
// size_t println(const __FlashStringHelper *);
// size_t println(const String &s);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);
size_t println(int, int = DEC);
size_t println(unsigned int, int = DEC);
size_t println(long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);
virtual void flush() { /* Empty implementation for backward compatibility */ };
};
#endif

View File

@ -0,0 +1,39 @@
/*
Printable.h - Interface class that allows printing of complex types
Copyright (c) 2011 Adrian McEwen. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef Printable_h
#define Printable_h
#include <stdlib.h>
class Print;
/** The Printable class provides a way for new classes to allow themselves to be printed.
By deriving from Printable and implementing the printTo method, it will then be possible
for users to print out instances of this class by passing them into the usual
Print::print and Print::println methods.
*/
class Printable
{
public:
virtual size_t printTo(Print& p) const = 0;
};
#endif

View File

@ -0,0 +1,76 @@
/*
U8g2lib.cpp
Arduino specific functions
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
Copyright (c) 2016, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "U8g2lib.h"
static Print *u8g2_print_for_screenshot;
void u8g2_print_callback(const char *s)
{
// yield();
u8g2_print_for_screenshot->print(s);
}
void U8G2::writeBufferPBM(Print &p)
{
u8g2_print_for_screenshot = &p;
u8g2_WriteBufferPBM(getU8g2(), u8g2_print_callback);
}
void U8G2::writeBufferXBM(Print &p)
{
u8g2_print_for_screenshot = &p;
u8g2_WriteBufferXBM(getU8g2(), u8g2_print_callback);
}
void U8G2::writeBufferPBM2(Print &p)
{
u8g2_print_for_screenshot = &p;
u8g2_WriteBufferPBM2(getU8g2(), u8g2_print_callback);
}
void U8G2::writeBufferXBM2(Print &p)
{
u8g2_print_for_screenshot = &p;
u8g2_WriteBufferXBM2(getU8g2(), u8g2_print_callback);
}

14021
sys/arm-linux/port/U8g2lib.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

4912
sys/arm-linux/port/U8x8lib.h Normal file

File diff suppressed because it is too large Load Diff