mirror of
https://github.com/nodemcu/nodemcu-firmware.git
synced 2025-01-16 20:52:57 +08:00
Merge pull request #2184 from devsaurus/u8g2_port
Replace u8glib with u8g2
This commit is contained in:
commit
c6f6c54bc8
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "app/u8g2lib/u8g2"]
|
||||
path = app/u8g2lib/u8g2
|
||||
url = https://github.com/olikraus/U8g2_Arduino.git
|
12
Makefile
12
Makefile
@ -308,11 +308,11 @@ endif
|
||||
|
||||
|
||||
$(OBJODIR)/%.o: %.c
|
||||
@mkdir -p $(OBJODIR);
|
||||
@mkdir -p $(dir $@);
|
||||
$(CC) $(if $(findstring $<,$(DSRCS)),$(DFLAGS),$(CFLAGS)) $(COPTS_$(*F)) -o $@ -c $<
|
||||
|
||||
$(OBJODIR)/%.d: %.c
|
||||
@mkdir -p $(OBJODIR);
|
||||
@mkdir -p $(dir $@);
|
||||
@echo DEPEND: $(CC) -M $(CFLAGS) $<
|
||||
@set -e; rm -f $@; \
|
||||
$(CC) -M $(CFLAGS) $< > $@.$$$$; \
|
||||
@ -331,22 +331,22 @@ $(OBJODIR)/%.d: %.cpp
|
||||
rm -f $@.$$$$
|
||||
|
||||
$(OBJODIR)/%.o: %.s
|
||||
@mkdir -p $(OBJODIR);
|
||||
@mkdir -p $(dir $@);
|
||||
$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
$(OBJODIR)/%.d: %.s
|
||||
@mkdir -p $(OBJODIR); \
|
||||
@mkdir -p $(dir $@); \
|
||||
set -e; rm -f $@; \
|
||||
$(CC) -M $(CFLAGS) $< > $@.$$$$; \
|
||||
sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
|
||||
rm -f $@.$$$$
|
||||
|
||||
$(OBJODIR)/%.o: %.S
|
||||
@mkdir -p $(OBJODIR);
|
||||
@mkdir -p $(dir $@);
|
||||
$(CC) $(CFLAGS) -D__ASSEMBLER__ -o $@ -c $<
|
||||
|
||||
$(OBJODIR)/%.d: %.S
|
||||
@mkdir -p $(OBJODIR); \
|
||||
@mkdir -p $(dir $@); \
|
||||
set -e; rm -f $@; \
|
||||
$(CC) -M $(CFLAGS) $< > $@.$$$$; \
|
||||
sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
|
||||
|
@ -21,7 +21,7 @@ ifndef PDIR # {
|
||||
GEN_IMAGES= eagle.app.v6.out
|
||||
GEN_BINS= eagle.app.v6.bin
|
||||
OPT_MKTARGETS := coap crypto dht http mqtt pcm sjson sqlite3 tsl2561 websocket
|
||||
OPT_MKLIBTARGETS := u8g ucg
|
||||
OPT_MKLIBTARGETS := u8g2 ucg
|
||||
SEL_MKTARGETS := $(shell $(CC) -E -dM include/user_modules.h | sed -n '/^\#define LUA_USE_MODULES_/{s/.\{24\}\(.*\)/\L\1/; p}')
|
||||
OPT_SEL_MKLIBTARGETS := $(foreach tgt,$(OPT_MKLIBTARGETS),$(findstring $(tgt), $(SEL_MKTARGETS)))
|
||||
OPT_SEL_MKTARGETS := $(foreach tgt,$(OPT_MKTARGETS),$(findstring $(tgt), $(SEL_MKTARGETS))) \
|
||||
|
121
app/include/u8g2_displays.h
Normal file
121
app/include/u8g2_displays.h
Normal file
@ -0,0 +1,121 @@
|
||||
|
||||
#ifndef _U8G2_DISPLAYS_H
|
||||
#define _U8G2_DISPLAYS_H
|
||||
|
||||
#define U8G2_DISPLAY_TABLE_ENTRY(function, binding)
|
||||
|
||||
// ***************************************************************************
|
||||
// Enable display drivers
|
||||
//
|
||||
// Uncomment the U8G2_DISPLAY_TABLE_ENTRY for the device(s) you want to
|
||||
// compile into the firmware.
|
||||
// Stick to the assignments to *_I2C and *_SPI tables.
|
||||
|
||||
#ifndef U8G2_DISPLAY_TABLE_I2C_EXTRA
|
||||
|
||||
// I2C based displays go into here:
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1610_i2c_ea_dogxl160_f, uc1610_i2c_ea_dogxl160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1325_i2c_nhd_128x64_f, ssd1325_i2c_nhd_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_64x48_er_f, ssd1306_i2c_64x48_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_i2c_erc24064_f, uc1608_i2c_erc24064) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7588_i2c_jlx12864_f, st7588_i2c_jlx12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_i2c_128x64_noname0_f, ssd1309_i2c_128x64_noname0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_i2c_ea_dogxl240_f, uc1611_i2c_ea_dogxl240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1305_i2c_128x32_noname_f, ssd1305_i2c_128x32_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x32_univision_f, ssd1306_i2c_128x32_univision) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_i2c_240x128_f, uc1608_i2c_240x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ld7032_i2c_60x32_f, ld7032_i2c_60x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_i2c_ew50850_f, uc1611_i2c_ew50850) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1604_i2c_jlx19264_f, uc1604_i2c_jlx19264) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1601_i2c_128x32_f, uc1601_i2c_128x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1106_i2c_128x64_vcomh0_f, sh1106_i2c_128x64_vcomh0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_96x16_er_f, ssd1306_i2c_96x16_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1106_i2c_128x64_noname_f, sh1106_i2c_128x64_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x64_vcomh0_f, ssd1306_i2c_128x64_vcomh0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x64_noname_f, ssd1306_i2c_128x64_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_i2c_128x64_noname2_f, ssd1309_i2c_128x64_noname2) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_i2c_ea_dogm240_f, uc1611_i2c_ea_dogm240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_i2c_seeed_96x96_f, ssd1327_i2c_seeed_96x96) \
|
||||
|
||||
#define U8G2_DISPLAY_TABLE_I2C \
|
||||
U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x64_noname_f, ssd1306_i2c_128x64_noname) \
|
||||
|
||||
#else
|
||||
|
||||
// I2C displays can be defined in an external file.
|
||||
#define U8G2_DISPLAY_TABLE_I2C \
|
||||
U8G2_DISPLAY_TABLE_I2C_EXTRA
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef U8G2_DISPLAY_TABLE_SPI_EXTRA
|
||||
|
||||
// SPI based displays go into here:
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1606_172x72_f, ssd1606_172x72) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_240x128_f, uc1608_240x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_erc12864_f, st7565_erc12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_128x64_noname0_f, ssd1309_128x64_noname0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1601_128x32_f, uc1601_128x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_erc24064_f, uc1608_erc24064) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_lm6059_f, st7565_lm6059) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_ea_dogxl240_f, uc1611_ea_dogxl240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_nhd_c12864_f, st7565_nhd_c12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_vcomh0_f, ssd1306_128x64_vcomh0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1305_128x32_noname_f, ssd1305_128x32_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_max7219_32x8_f, max7219_32x8) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ls013b7dh03_128x128_f, ls013b7dh03_128x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_il3820_v2_296x128_f, il3820_v2_296x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1610_ea_dogxl160_f, uc1610_ea_dogxl160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_ea_dogm240_f, uc1611_ea_dogm240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1604_jlx19264_f, uc1604_jlx19264) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7920_s_192x32_f, st7920_s_192x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1325_nhd_128x64_f, ssd1325_nhd_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_noname_f, ssd1306_128x64_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sed1520_122x32_f, sed1520_122x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_ea_dogm128_f, st7565_ea_dogm128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ld7032_60x32_f, ld7032_60x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1607_200x200_f, ssd1607_200x200) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_128x64_noname2_f, ssd1309_128x64_noname2) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1106_128x64_noname_f, sh1106_128x64_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x32_univision_f, ssd1306_128x32_univision) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7920_s_128x64_f, st7920_s_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_64128n_f, st7565_64128n) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1701_ea_dogs102_f, uc1701_ea_dogs102) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_ew50850_f, uc1611_ew50850) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1322_nhd_256x64_f, ssd1322_nhd_256x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_ea_dogm132_f, st7565_ea_dogm132) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1329_128x96_noname_f, ssd1329_128x96_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_zolen_128x64_f, st7565_zolen_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx256128_f, st75256_jlx256128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_96x16_er_f, ssd1306_96x16_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ist3020_erc19264_f, ist3020_erc19264) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7588_jlx12864_f, st7588_jlx12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_seeed_96x96_f, ssd1327_seeed_96x96) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx172104_f, st75256_jlx172104) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_nhd_c12832_f, st7565_nhd_c12832) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_64x48_er_f, ssd1306_64x48_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_pcf8812_96x65_f, pcf8812_96x65) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7567_pi_132x64_f, st7567_pi_132x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7567_jlx12864_f, st7567_jlx12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_pcd8544_84x48_f, pcd8544_84x48) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1106_128x64_vcomh0_f, sh1106_128x64_vcomh0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_nt7534_tg12864r_f, nt7534_tg12864r) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1701_mini12864_f, uc1701_mini12864) \
|
||||
|
||||
#define U8G2_DISPLAY_TABLE_SPI \
|
||||
U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_noname_f, ssd1306_128x64_noname) \
|
||||
|
||||
#else
|
||||
|
||||
// SPI displays can be defined in an external file.
|
||||
#define U8G2_DISPLAY_TABLE_SPI \
|
||||
U8G2_DISPLAY_TABLE_SPI_EXTRA
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
#endif /* _U8G2_DISPLAYS_H */
|
27
app/include/u8g2_fonts.h
Normal file
27
app/include/u8g2_fonts.h
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
#ifndef _U8G2_FONTS_H
|
||||
#define _U8G2_FONTS_H
|
||||
|
||||
#define U8G2_FONT_TABLE_ENTRY(font)
|
||||
|
||||
// ***************************************************************************
|
||||
// Configure U8glib fonts
|
||||
//
|
||||
#ifndef U8G2_FONT_TABLE_EXTRA
|
||||
//
|
||||
// Add a U8G2_FONT_TABLE_ENTRY for each font you want to compile into the image
|
||||
#define U8G2_FONT_TABLE \
|
||||
U8G2_FONT_TABLE_ENTRY(font_6x10_tf) \
|
||||
U8G2_FONT_TABLE_ENTRY(font_unifont_t_symbols) \
|
||||
|
||||
#else
|
||||
//
|
||||
// The font table can be defined in an external file.
|
||||
#define U8G2_FONT_TABLE \
|
||||
U8G2_FONT_TABLE_EXTRA
|
||||
|
||||
#endif
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
#endif /* _U8G2_FONTS_H */
|
@ -1,88 +0,0 @@
|
||||
#ifndef __U8G_CONFIG_H__
|
||||
#define __U8G_CONFIG_H__
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// Configure U8glib fonts
|
||||
//
|
||||
// Add a U8G_FONT_TABLE_ENTRY for each font you want to compile into the image
|
||||
#define U8G_FONT_TABLE_ENTRY(font)
|
||||
#define U8G_FONT_TABLE \
|
||||
U8G_FONT_TABLE_ENTRY(font_6x10) \
|
||||
U8G_FONT_TABLE_ENTRY(font_chikita)
|
||||
#undef U8G_FONT_TABLE_ENTRY
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// Enable display drivers
|
||||
//
|
||||
// Uncomment the U8G_DISPLAY_TABLE_ENTRY for the device(s) you want to
|
||||
// compile into the firmware.
|
||||
// Stick to the assignments to *_I2C and *_SPI tables.
|
||||
//
|
||||
// I2C based displays go into here:
|
||||
// U8G_DISPLAY_TABLE_ENTRY(sh1106_128x64_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x32_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_64x48_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1309_128x64_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1327_96x96_gr_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1611_dogm240_i2c) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1611_dogxl240_i2c) \
|
||||
|
||||
#define U8G_DISPLAY_TABLE_ENTRY(device)
|
||||
#define U8G_DISPLAY_TABLE_I2C \
|
||||
U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_i2c) \
|
||||
|
||||
// SPI based displays go into here:
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ld7032_60x32_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(pcd8544_84x48_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(pcf8812_96x65_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(sh1106_128x64_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x32_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_64x48_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1309_128x64_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1322_nhd31oled_bw_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1322_nhd31oled_gr_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1325_nhd27oled_bw_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1325_nhd27oled_gr_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1327_96x96_gr_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1351_128x128_332_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1351_128x128gh_332_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1351_128x128_hicolor_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1351_128x128gh_hicolor_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1353_160x128_332_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(ssd1353_160x128_hicolor_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_64128n_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_dogm128_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_dogm132_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_lm6059_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_lm6063_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_nhd_c12832_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(st7565_nhd_c12864_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1601_c128032_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1608_240x128_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1608_240x64_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1610_dogxl160_bw_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1610_dogxl160_gr_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1611_dogm240_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1611_dogxl240_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1701_dogs102_hw_spi) \
|
||||
// U8G_DISPLAY_TABLE_ENTRY(uc1701_mini12864_hw_spi) \
|
||||
|
||||
#define U8G_DISPLAY_TABLE_SPI \
|
||||
U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_hw_spi) \
|
||||
|
||||
#undef U8G_DISPLAY_TABLE_ENTRY
|
||||
|
||||
// Special display device to provide run-length encoded framebuffer contents
|
||||
// to a Lua callback:
|
||||
//#define U8G_DISPLAY_FB_RLE
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
|
||||
#endif /* __U8G_CONFIG_H__ */
|
@ -64,8 +64,8 @@
|
||||
//#define LUA_USE_MODULES_TLS
|
||||
#define LUA_USE_MODULES_TMR
|
||||
//#define LUA_USE_MODULES_TSL2561
|
||||
//#define LUA_USE_MODULES_U8G
|
||||
#define LUA_USE_MODULES_UART
|
||||
//#define LUA_USE_MODULES_U8G2
|
||||
//#define LUA_USE_MODULES_UCG
|
||||
//#define LUA_USE_MODULES_WEBSOCKET
|
||||
#define LUA_USE_MODULES_WIFI
|
||||
|
@ -43,7 +43,7 @@ INCLUDES += -I ./
|
||||
INCLUDES += -I ../libc
|
||||
INCLUDES += -I ../coap
|
||||
INCLUDES += -I ../mqtt
|
||||
INCLUDES += -I ../u8glib
|
||||
INCLUDES += -I ../u8g2lib/u8g2/src/clib
|
||||
INCLUDES += -I ../ucglib
|
||||
INCLUDES += -I ../lua
|
||||
INCLUDES += -I ../pcm
|
||||
|
1003
app/modules/u8g.c
1003
app/modules/u8g.c
File diff suppressed because it is too large
Load Diff
808
app/modules/u8g2.c
Normal file
808
app/modules/u8g2.c
Normal file
@ -0,0 +1,808 @@
|
||||
// Module for binding the u8g2 library
|
||||
// Note: This file is intended to be shared between esp8266 and esp32 platform
|
||||
|
||||
#include "module.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#define U8X8_USE_PINS
|
||||
#include "u8g2.h"
|
||||
#include "u8x8_nodemcu_hal.h"
|
||||
|
||||
#include "u8g2_displays.h"
|
||||
#include "u8g2_fonts.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
// ESP32
|
||||
#include "spi_common.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_LUA_MODULE_U8G2
|
||||
// ignore unused functions if u8g2 module will be skipped anyhow
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
int font_ref;
|
||||
int host_ref;
|
||||
u8g2_nodemcu_t u8g2;
|
||||
} u8g2_ud_t;
|
||||
|
||||
#define GET_U8G2() \
|
||||
u8g2_ud_t *ud = (u8g2_ud_t *)luaL_checkudata( L, 1, "u8g2.display" ); \
|
||||
u8g2_t *u8g2 = (u8g2_t *)(&(ud->u8g2));
|
||||
|
||||
static int lu8g2_clearBuffer( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
|
||||
u8g2_ClearBuffer( u8g2 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawBox( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x = luaL_checkint( L, ++stack );
|
||||
int y = luaL_checkint( L, ++stack );
|
||||
int w = luaL_checkint( L, ++stack );
|
||||
int h = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_DrawBox( u8g2, x, y, w, h );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawCircle( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x0 = luaL_checkint( L, ++stack );
|
||||
int y0 = luaL_checkint( L, ++stack );
|
||||
int rad = luaL_checkint( L, ++stack );
|
||||
int opt = luaL_optint( L, ++stack, U8G2_DRAW_ALL );
|
||||
|
||||
u8g2_DrawCircle( u8g2, x0, y0, rad, opt );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawDisc( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x0 = luaL_checkint( L, ++stack );
|
||||
int y0 = luaL_checkint( L, ++stack );
|
||||
int rad = luaL_checkint( L, ++stack );
|
||||
int opt = luaL_optint( L, ++stack, U8G2_DRAW_ALL );
|
||||
|
||||
u8g2_DrawDisc( u8g2, x0, y0, rad, opt );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawEllipse( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x0 = luaL_checkint( L, ++stack );
|
||||
int y0 = luaL_checkint( L, ++stack );
|
||||
int rx = luaL_checkint( L, ++stack );
|
||||
int ry = luaL_checkint( L, ++stack );
|
||||
int opt = luaL_optint( L, ++stack, U8G2_DRAW_ALL );
|
||||
|
||||
u8g2_DrawEllipse( u8g2, x0, y0, rx, ry, opt );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawFilledEllipse( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x0 = luaL_checkint( L, ++stack );
|
||||
int y0 = luaL_checkint( L, ++stack );
|
||||
int rx = luaL_checkint( L, ++stack );
|
||||
int ry = luaL_checkint( L, ++stack );
|
||||
int opt = luaL_optint( L, ++stack, U8G2_DRAW_ALL );
|
||||
|
||||
u8g2_DrawFilledEllipse( u8g2, x0, y0, rx, ry, opt );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawFrame( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x = luaL_checkint( L, ++stack );
|
||||
int y = luaL_checkint( L, ++stack );
|
||||
int w = luaL_checkint( L, ++stack );
|
||||
int h = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_DrawFrame( u8g2, x, y, w, h );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawGlyph( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x = luaL_checkint( L, ++stack );
|
||||
int y = luaL_checkint( L, ++stack );
|
||||
int enc = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_DrawGlyph( u8g2, x, y, enc );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawHLine( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x = luaL_checkint( L, ++stack );
|
||||
int y = luaL_checkint( L, ++stack );
|
||||
int w = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_DrawHLine( u8g2, x, y, w );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawLine( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x0 = luaL_checkint( L, ++stack );
|
||||
int y0 = luaL_checkint( L, ++stack );
|
||||
int x1 = luaL_checkint( L, ++stack );
|
||||
int y1 = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_DrawLine( u8g2, x0, y0, x1, y1 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawPixel( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x = luaL_checkint( L, ++stack );
|
||||
int y = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_DrawPixel( u8g2, x, y );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawRBox( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x = luaL_checkint( L, ++stack );
|
||||
int y = luaL_checkint( L, ++stack );
|
||||
int w = luaL_checkint( L, ++stack );
|
||||
int h = luaL_checkint( L, ++stack );
|
||||
int r = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_DrawRBox( u8g2, x, y, w, h, r );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawRFrame( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x = luaL_checkint( L, ++stack );
|
||||
int y = luaL_checkint( L, ++stack );
|
||||
int w = luaL_checkint( L, ++stack );
|
||||
int h = luaL_checkint( L, ++stack );
|
||||
int r = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_DrawRFrame( u8g2, x, y, w, h, r );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawStr( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x = luaL_checkint( L, ++stack );
|
||||
int y = luaL_checkint( L, ++stack );
|
||||
const char *str = luaL_checkstring( L, ++stack );
|
||||
|
||||
u8g2_DrawStr( u8g2, x, y, str );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawTriangle( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x0 = luaL_checkint( L, ++stack );
|
||||
int y0 = luaL_checkint( L, ++stack );
|
||||
int x1 = luaL_checkint( L, ++stack );
|
||||
int y1 = luaL_checkint( L, ++stack );
|
||||
int x2 = luaL_checkint( L, ++stack );
|
||||
int y2 = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_DrawTriangle( u8g2, x0, y0, x1, y1, x2, y2 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawUTF8( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x = luaL_checkint( L, ++stack );
|
||||
int y = luaL_checkint( L, ++stack );
|
||||
const char *str = luaL_checkstring( L, ++stack );
|
||||
|
||||
u8g2_DrawUTF8( u8g2, x, y, str );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawVLine( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x = luaL_checkint( L, ++stack );
|
||||
int y = luaL_checkint( L, ++stack );
|
||||
int h = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_DrawVLine( u8g2, x, y, h );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_drawXBM( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int x = luaL_checkint( L, ++stack );
|
||||
int y = luaL_checkint( L, ++stack );
|
||||
int w = luaL_checkint( L, ++stack );
|
||||
int h = luaL_checkint( L, ++stack );
|
||||
size_t len;
|
||||
const char *bitmap = luaL_checklstring( L, ++stack, &len );
|
||||
|
||||
u8g2_DrawXBM( u8g2, x, y, w, h, (uint8_t *)bitmap );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_getAscent( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
|
||||
lua_pushinteger( L, u8g2_GetAscent( u8g2 ) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lu8g2_getDescent( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
|
||||
lua_pushinteger( L, u8g2_GetDescent( u8g2 ) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lu8g2_getStrWidth( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
const char *s = luaL_checkstring( L, ++stack );
|
||||
|
||||
lua_pushinteger( L, u8g2_GetStrWidth( u8g2, s ) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lu8g2_getUTF8Width( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
const char *s = luaL_checkstring( L, ++stack );
|
||||
|
||||
lua_pushinteger( L, u8g2_GetUTF8Width( u8g2, s ) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lu8g2_sendBuffer( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
|
||||
u8g2_SendBuffer( u8g2 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setBitmapMode( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int is_transparent = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_SetBitmapMode( u8g2, is_transparent );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setContrast( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int value = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_SetContrast( u8g2, value );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setDisplayRotation( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
const u8g2_cb_t *u8g2_cb = (u8g2_cb_t *)lua_touserdata( L, ++stack );
|
||||
|
||||
u8g2_SetDisplayRotation( u8g2, u8g2_cb );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setDrawColor( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int col = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_SetDrawColor( u8g2, col );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setFlipMode( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int is_enable = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_SetFlipMode( u8g2, is_enable );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setFont( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
const uint8_t *font = NULL;
|
||||
|
||||
luaL_unref( L, LUA_REGISTRYINDEX, ud->font_ref );
|
||||
ud->font_ref = LUA_NOREF;
|
||||
|
||||
if (lua_islightuserdata( L, ++stack )) {
|
||||
font = (const uint8_t *)lua_touserdata( L, stack );
|
||||
|
||||
} else if (lua_isstring( L, stack )) {
|
||||
// ref the font string to safe it in case the string variable gets gc'ed
|
||||
lua_pushvalue( L, stack );
|
||||
ud->font_ref = luaL_ref( L, LUA_REGISTRYINDEX );
|
||||
|
||||
size_t len;
|
||||
font = (const uint8_t *)luaL_checklstring( L, stack, &len );
|
||||
|
||||
}
|
||||
luaL_argcheck( L, font != NULL, stack, "invalid font" );
|
||||
|
||||
u8g2_SetFont( u8g2, font );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setFontDirection( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int dir = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_SetFontDirection( u8g2, dir );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setFontMode( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int is_transparent = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_SetFontMode( u8g2, is_transparent );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setFontPosBaseline( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
|
||||
u8g2_SetFontPosBaseline( u8g2 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setFontPosBottom( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
|
||||
u8g2_SetFontPosBottom( u8g2 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setFontPosTop( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
|
||||
u8g2_SetFontPosTop( u8g2 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setFontPosCenter( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
|
||||
u8g2_SetFontPosCenter( u8g2 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setFontRefHeightAll( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
|
||||
u8g2_SetFontRefHeightAll( u8g2 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setFontRefHeightExtendedText( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
|
||||
u8g2_SetFontRefHeightExtendedText( u8g2 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setFontRefHeightText( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
|
||||
u8g2_SetFontRefHeightText( u8g2 );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lu8g2_setPowerSave( lua_State *L )
|
||||
{
|
||||
GET_U8G2();
|
||||
int stack = 1;
|
||||
|
||||
int is_enable = luaL_checkint( L, ++stack );
|
||||
|
||||
u8g2_SetPowerSave( u8g2, is_enable );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static const LUA_REG_TYPE lu8g2_display_map[] = {
|
||||
{ LSTRKEY( "clearBuffer" ), LFUNCVAL( lu8g2_clearBuffer ) },
|
||||
{ LSTRKEY( "drawBox" ), LFUNCVAL( lu8g2_drawBox ) },
|
||||
{ LSTRKEY( "drawCircle" ), LFUNCVAL( lu8g2_drawCircle ) },
|
||||
{ LSTRKEY( "drawDisc" ), LFUNCVAL( lu8g2_drawDisc ) },
|
||||
{ LSTRKEY( "drawEllipse" ), LFUNCVAL( lu8g2_drawEllipse ) },
|
||||
{ LSTRKEY( "drawFilledEllipse" ), LFUNCVAL( lu8g2_drawFilledEllipse ) },
|
||||
{ LSTRKEY( "drawFrame" ), LFUNCVAL( lu8g2_drawFrame ) },
|
||||
{ LSTRKEY( "drawGlyph" ), LFUNCVAL( lu8g2_drawGlyph ) },
|
||||
{ LSTRKEY( "drawHLine" ), LFUNCVAL( lu8g2_drawHLine ) },
|
||||
{ LSTRKEY( "drawLine" ), LFUNCVAL( lu8g2_drawLine ) },
|
||||
{ LSTRKEY( "drawPixel" ), LFUNCVAL( lu8g2_drawPixel ) },
|
||||
{ LSTRKEY( "drawRBox" ), LFUNCVAL( lu8g2_drawRBox ) },
|
||||
{ LSTRKEY( "drawRFrame" ), LFUNCVAL( lu8g2_drawRFrame ) },
|
||||
{ LSTRKEY( "drawStr" ), LFUNCVAL( lu8g2_drawStr ) },
|
||||
{ LSTRKEY( "drawTriangle" ), LFUNCVAL( lu8g2_drawTriangle ) },
|
||||
{ LSTRKEY( "drawUTF8" ), LFUNCVAL( lu8g2_drawUTF8 ) },
|
||||
{ LSTRKEY( "drawVLine" ), LFUNCVAL( lu8g2_drawVLine ) },
|
||||
{ LSTRKEY( "drawXBM" ), LFUNCVAL( lu8g2_drawXBM ) },
|
||||
{ LSTRKEY( "getAscent" ), LFUNCVAL( lu8g2_getAscent ) },
|
||||
{ LSTRKEY( "getDescent" ), LFUNCVAL( lu8g2_getDescent ) },
|
||||
{ LSTRKEY( "getStrWidth" ), LFUNCVAL( lu8g2_getStrWidth ) },
|
||||
{ LSTRKEY( "getUTF8Width" ), LFUNCVAL( lu8g2_getUTF8Width ) },
|
||||
{ LSTRKEY( "sendBuffer" ), LFUNCVAL( lu8g2_sendBuffer ) },
|
||||
{ LSTRKEY( "setBitmapMode" ), LFUNCVAL( lu8g2_setBitmapMode ) },
|
||||
{ LSTRKEY( "setContrast" ), LFUNCVAL( lu8g2_setContrast ) },
|
||||
{ LSTRKEY( "setDisplayRotation" ), LFUNCVAL( lu8g2_setDisplayRotation ) },
|
||||
{ LSTRKEY( "setDrawColor" ), LFUNCVAL( lu8g2_setDrawColor ) },
|
||||
{ LSTRKEY( "setFlipMode" ), LFUNCVAL( lu8g2_setFlipMode ) },
|
||||
{ LSTRKEY( "setFont" ), LFUNCVAL( lu8g2_setFont ) },
|
||||
{ LSTRKEY( "setFontDirection" ), LFUNCVAL( lu8g2_setFontDirection ) },
|
||||
{ LSTRKEY( "setFontMode" ), LFUNCVAL( lu8g2_setFontMode ) },
|
||||
{ LSTRKEY( "setFontPosBaseline" ), LFUNCVAL( lu8g2_setFontPosBaseline ) },
|
||||
{ LSTRKEY( "setFontPosBottom" ), LFUNCVAL( lu8g2_setFontPosBottom ) },
|
||||
{ LSTRKEY( "setFontPosTop" ), LFUNCVAL( lu8g2_setFontPosTop ) },
|
||||
{ LSTRKEY( "setFontPosCenter" ), LFUNCVAL( lu8g2_setFontPosCenter ) },
|
||||
{ LSTRKEY( "setFontRefHeightAll" ), LFUNCVAL( lu8g2_setFontRefHeightAll ) },
|
||||
{ LSTRKEY( "setFontRefHeightExtendedText" ), LFUNCVAL( lu8g2_setFontRefHeightExtendedText ) },
|
||||
{ LSTRKEY( "setFontRefHeightText" ), LFUNCVAL( lu8g2_setFontRefHeightText ) },
|
||||
{ LSTRKEY( "setPowerSave" ), LFUNCVAL( lu8g2_setPowerSave ) },
|
||||
//{ LSTRKEY( "__gc" ), LFUNCVAL( lu8g2_display_free ) },
|
||||
{ LSTRKEY( "__index" ), LROVAL( lu8g2_display_map ) },
|
||||
{LNILKEY, LNILVAL}
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8x8_d_overlay(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
|
||||
typedef void (*display_setup_fn_t)(u8g2_t *u8g2, const u8g2_cb_t *rotation, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb);
|
||||
|
||||
// ***************************************************************************
|
||||
// Device constructors
|
||||
//
|
||||
// I2C based devices will use this function template to implement the Lua binding.
|
||||
//
|
||||
static int ldisplay_i2c( lua_State *L, display_setup_fn_t setup_fn )
|
||||
{
|
||||
int stack = 0;
|
||||
|
||||
int id = -1;
|
||||
int i2c_addr = -1;
|
||||
int rfb_cb_ref = LUA_NOREF;
|
||||
|
||||
if (lua_type( L, ++stack) == LUA_TNUMBER) {
|
||||
/* hardware display connected */
|
||||
id = luaL_checkint( L, stack );
|
||||
i2c_addr = luaL_checkint( L, ++stack );
|
||||
luaL_argcheck( L, i2c_addr >= 0 && i2c_addr <= 0x7f, stack, "invalid i2c address" );
|
||||
} else
|
||||
stack--;
|
||||
if (lua_isfunction( L, ++stack )) {
|
||||
lua_pushvalue( L, stack );
|
||||
rfb_cb_ref = luaL_ref( L, LUA_REGISTRYINDEX );
|
||||
}
|
||||
if (id < 0 && rfb_cb_ref == LUA_NOREF)
|
||||
return luaL_error( L, "wrong args" );
|
||||
|
||||
u8g2_ud_t *ud = (u8g2_ud_t *)lua_newuserdata( L, sizeof( u8g2_ud_t ) );
|
||||
u8g2_nodemcu_t *ext_u8g2 = &(ud->u8g2);
|
||||
ud->font_ref = LUA_NOREF;
|
||||
ud->host_ref = LUA_NOREF;
|
||||
/* the i2c driver id is forwarded in the hal member */
|
||||
ext_u8g2->hal = id >= 0 ? (void *)id : NULL;
|
||||
|
||||
u8g2_t *u8g2 = (u8g2_t *)ext_u8g2;
|
||||
u8x8_t *u8x8 = (u8x8_t *)u8g2;
|
||||
|
||||
setup_fn( u8g2, U8G2_R0, u8x8_byte_nodemcu_i2c, u8x8_gpio_and_delay_nodemcu );
|
||||
|
||||
/* prepare overlay data */
|
||||
if (rfb_cb_ref != LUA_NOREF) {
|
||||
ext_u8g2->overlay.template_display_cb = u8x8->display_cb;
|
||||
ext_u8g2->overlay.hardware_display_cb = NULL;
|
||||
ext_u8g2->overlay.rfb_cb_ref = LUA_NOREF;
|
||||
u8x8->display_cb = u8x8_d_overlay;
|
||||
}
|
||||
if (id >= 0) {
|
||||
/* hardware device specific initialization */
|
||||
u8x8_SetI2CAddress( u8x8, i2c_addr );
|
||||
ext_u8g2->overlay.hardware_display_cb = ext_u8g2->overlay.template_display_cb;
|
||||
}
|
||||
|
||||
u8g2_InitDisplay( (u8g2_t *)u8g2 );
|
||||
u8g2_ClearDisplay( (u8g2_t *)u8g2 );
|
||||
u8g2_SetPowerSave( (u8g2_t *)u8g2, 0 );
|
||||
|
||||
if (rfb_cb_ref != LUA_NOREF) {
|
||||
/* finally enable rfb display driver */
|
||||
ext_u8g2->overlay.rfb_cb_ref = rfb_cb_ref;
|
||||
}
|
||||
|
||||
/* set its metatable */
|
||||
luaL_getmetatable(L, "u8g2.display");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
//
|
||||
// SPI based devices will use this function template to implement the Lua binding.
|
||||
//
|
||||
static int ldisplay_spi( lua_State *L, display_setup_fn_t setup_fn )
|
||||
{
|
||||
int stack = 0;
|
||||
|
||||
#ifndef ESP_PLATFORM
|
||||
// ESP8266
|
||||
typedef struct {
|
||||
int host;
|
||||
} lspi_host_t;
|
||||
lspi_host_t host_elem;
|
||||
lspi_host_t *host = &host_elem;
|
||||
#else
|
||||
// ESP32
|
||||
lspi_host_t *host = NULL;
|
||||
#endif
|
||||
int host_ref = LUA_NOREF;
|
||||
int cs = -1;
|
||||
int dc = -1;
|
||||
int res = -1;
|
||||
int rfb_cb_ref = LUA_NOREF;
|
||||
int get_spi_pins;
|
||||
|
||||
|
||||
if (lua_type( L, ++stack ) == LUA_TUSERDATA) {
|
||||
host = (lspi_host_t *)luaL_checkudata( L, stack, "spi.master" );
|
||||
/* reference host object to avoid automatic gc */
|
||||
lua_pushvalue( L, stack );
|
||||
host_ref = luaL_ref( L, LUA_REGISTRYINDEX );
|
||||
get_spi_pins = 1;
|
||||
} else if (lua_type( L, stack ) == LUA_TNUMBER) {
|
||||
host->host = luaL_checkint( L, stack );
|
||||
get_spi_pins = 1;
|
||||
} else {
|
||||
get_spi_pins = 0;
|
||||
stack--;
|
||||
}
|
||||
|
||||
if (get_spi_pins) {
|
||||
cs = luaL_checkint( L, ++stack );
|
||||
dc = luaL_checkint( L, ++stack );
|
||||
res = luaL_optint( L, ++stack, -1 );
|
||||
}
|
||||
|
||||
if (lua_isfunction( L, ++stack )) {
|
||||
lua_pushvalue( L, stack );
|
||||
rfb_cb_ref = luaL_ref( L, LUA_REGISTRYINDEX );
|
||||
}
|
||||
if (!host && rfb_cb_ref == LUA_NOREF)
|
||||
return luaL_error( L, "wrong args" );
|
||||
|
||||
u8g2_ud_t *ud = (u8g2_ud_t *)lua_newuserdata( L, sizeof( u8g2_ud_t ) );
|
||||
u8g2_nodemcu_t *ext_u8g2 = &(ud->u8g2);
|
||||
ud->font_ref = LUA_NOREF;
|
||||
ud->host_ref = host_ref;
|
||||
/* the spi host id is forwarded in the hal member */
|
||||
ext_u8g2->hal = host ? (void *)(host->host) : NULL;
|
||||
|
||||
u8g2_t *u8g2 = (u8g2_t *)ext_u8g2;
|
||||
u8x8_t *u8x8 = (u8x8_t *)u8g2;
|
||||
|
||||
setup_fn( u8g2, U8G2_R0, u8x8_byte_nodemcu_spi, u8x8_gpio_and_delay_nodemcu );
|
||||
|
||||
/* prepare overlay data */
|
||||
if (rfb_cb_ref != LUA_NOREF) {
|
||||
ext_u8g2->overlay.template_display_cb = u8x8->display_cb;
|
||||
ext_u8g2->overlay.hardware_display_cb = NULL;
|
||||
ext_u8g2->overlay.rfb_cb_ref = LUA_NOREF;
|
||||
u8x8->display_cb = u8x8_d_overlay;
|
||||
}
|
||||
if (host) {
|
||||
/* hardware specific device initialization */
|
||||
u8x8_SetPin( u8x8, U8X8_PIN_CS, cs );
|
||||
u8x8_SetPin( u8x8, U8X8_PIN_DC, dc );
|
||||
if (res >= 0)
|
||||
u8x8_SetPin( u8x8, U8X8_PIN_RESET, res );
|
||||
ext_u8g2->overlay.hardware_display_cb = ext_u8g2->overlay.template_display_cb;
|
||||
}
|
||||
|
||||
u8g2_InitDisplay( (u8g2_t *)u8g2 );
|
||||
u8g2_ClearDisplay( (u8g2_t *)u8g2 );
|
||||
u8g2_SetPowerSave( (u8g2_t *)u8g2, 0 );
|
||||
|
||||
if (rfb_cb_ref != LUA_NOREF) {
|
||||
/* finally enable rfb display driver */
|
||||
ext_u8g2->overlay.rfb_cb_ref = rfb_cb_ref;
|
||||
}
|
||||
|
||||
/* set its metatable */
|
||||
luaL_getmetatable(L, "u8g2.display");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
//
|
||||
//
|
||||
#undef U8G2_DISPLAY_TABLE_ENTRY
|
||||
#define U8G2_DISPLAY_TABLE_ENTRY(function, binding) \
|
||||
static int l ## binding( lua_State *L ) \
|
||||
{ \
|
||||
return ldisplay_i2c( L, function ); \
|
||||
}
|
||||
//
|
||||
// Unroll the display table and insert binding functions for I2C based displays.
|
||||
U8G2_DISPLAY_TABLE_I2C
|
||||
//
|
||||
//
|
||||
#undef U8G2_DISPLAY_TABLE_ENTRY
|
||||
#define U8G2_DISPLAY_TABLE_ENTRY(function, binding) \
|
||||
static int l ## binding( lua_State *L ) \
|
||||
{ \
|
||||
return ldisplay_spi( L, function ); \
|
||||
}
|
||||
//
|
||||
// Unroll the display table and insert binding functions for SPI based displays.
|
||||
U8G2_DISPLAY_TABLE_SPI
|
||||
//
|
||||
|
||||
|
||||
#undef U8G2_FONT_TABLE_ENTRY
|
||||
#undef U8G2_DISPLAY_TABLE_ENTRY
|
||||
#define U8G2_DISPLAY_TABLE_ENTRY(function, binding) \
|
||||
{ LSTRKEY( #binding ), LFUNCVAL( l ## binding ) },
|
||||
|
||||
static const LUA_REG_TYPE lu8g2_map[] = {
|
||||
U8G2_DISPLAY_TABLE_I2C
|
||||
U8G2_DISPLAY_TABLE_SPI
|
||||
//
|
||||
// Register fonts
|
||||
#define U8G2_FONT_TABLE_ENTRY(font) \
|
||||
{ LSTRKEY( #font ), LUDATA( (void *)(u8g2_ ## font) ) },
|
||||
U8G2_FONT_TABLE
|
||||
//
|
||||
{ LSTRKEY( "DRAW_UPPER_RIGHT" ), LNUMVAL( U8G2_DRAW_UPPER_RIGHT ) },
|
||||
{ LSTRKEY( "DRAW_UPPER_LEFT" ), LNUMVAL( U8G2_DRAW_UPPER_LEFT ) },
|
||||
{ LSTRKEY( "DRAW_LOWER_RIGHT" ), LNUMVAL( U8G2_DRAW_LOWER_RIGHT ) },
|
||||
{ LSTRKEY( "DRAW_LOWER_LEFT" ), LNUMVAL( U8G2_DRAW_LOWER_LEFT ) },
|
||||
{ LSTRKEY( "DRAW_ALL" ), LNUMVAL( U8G2_DRAW_ALL ) },
|
||||
{ LSTRKEY( "R0" ), LUDATA( (void *)U8G2_R0 ) },
|
||||
{ LSTRKEY( "R1" ), LUDATA( (void *)U8G2_R1 ) },
|
||||
{ LSTRKEY( "R2" ), LUDATA( (void *)U8G2_R2 ) },
|
||||
{ LSTRKEY( "R3" ), LUDATA( (void *)U8G2_R3 ) },
|
||||
{ LSTRKEY( "MIRROR" ), LUDATA( (void *)U8G2_MIRROR ) },
|
||||
{LNILKEY, LNILVAL}
|
||||
};
|
||||
|
||||
int luaopen_u8g2( lua_State *L ) {
|
||||
luaL_rometatable(L, "u8g2.display", (void *)lu8g2_display_map);
|
||||
return 0;
|
||||
}
|
||||
|
||||
NODEMCU_MODULE(U8G2, "u8g2", lu8g2_map, luaopen_u8g2);
|
@ -1,347 +0,0 @@
|
||||
/*
|
||||
Functions for integrating U8glib into the nodemcu platform.
|
||||
*/
|
||||
|
||||
#include "lauxlib.h"
|
||||
#include "platform.h"
|
||||
|
||||
#include "c_stdlib.h"
|
||||
|
||||
#include "u8g.h"
|
||||
#include "u8g_glue.h"
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// comm functions
|
||||
//
|
||||
#define I2C_CMD_MODE 0x000
|
||||
#define I2C_DATA_MODE 0x040
|
||||
|
||||
#define ESP_I2C_ID 0
|
||||
|
||||
|
||||
static uint8_t do_i2c_start(uint8_t id, uint8_t sla)
|
||||
{
|
||||
platform_i2c_send_start( id );
|
||||
|
||||
// ignore return value -> tolerate missing ACK
|
||||
platform_i2c_send_address( id, sla, PLATFORM_I2C_DIRECTION_TRANSMITTER );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint8_t u8g_com_esp8266_ssd_start_sequence(struct _lu8g_userdata_t *lu8g)
|
||||
{
|
||||
/* are we requested to set the a0 state? */
|
||||
if ( lu8g->u8g.pin_list[U8G_PI_SET_A0] == 0 )
|
||||
return 1;
|
||||
|
||||
/* setup bus, might be a repeated start */
|
||||
if ( do_i2c_start( ESP_I2C_ID, lu8g->i2c_addr ) == 0 )
|
||||
return 0;
|
||||
if ( lu8g->u8g.pin_list[U8G_PI_A0_STATE] == 0 )
|
||||
{
|
||||
// ignore return value -> tolerate missing ACK
|
||||
if ( platform_i2c_send_byte( ESP_I2C_ID, I2C_CMD_MODE ) == 0 )
|
||||
; //return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
platform_i2c_send_byte( ESP_I2C_ID, I2C_DATA_MODE );
|
||||
}
|
||||
|
||||
lu8g->u8g.pin_list[U8G_PI_SET_A0] = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void lu8g_digital_write( struct _lu8g_userdata_t *lu8g, uint8_t pin_index, uint8_t value )
|
||||
{
|
||||
uint8_t pin;
|
||||
|
||||
pin = lu8g->u8g.pin_list[pin_index];
|
||||
if ( pin != U8G_PIN_NONE )
|
||||
platform_gpio_write( pin, value );
|
||||
}
|
||||
|
||||
void u8g_Delay(u8g_t *u8g, uint16_t msec)
|
||||
{
|
||||
struct _lu8g_userdata_t *lu8g = (struct _lu8g_userdata_t *)u8g;
|
||||
const uint16_t chunk = 50;
|
||||
|
||||
if (lu8g->use_delay == 0)
|
||||
return;
|
||||
|
||||
while (msec > chunk)
|
||||
{
|
||||
os_delay_us( chunk*1000 );
|
||||
msec -= chunk;
|
||||
}
|
||||
if (msec > 0)
|
||||
os_delay_us( msec*1000 );
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
os_delay_us( 1 );
|
||||
}
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
os_delay_us( 10 );
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_esp8266_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
struct _lu8g_userdata_t *lu8g = (struct _lu8g_userdata_t *)u8g;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_INIT:
|
||||
// we assume that the SPI interface was already initialized
|
||||
// just care for the /CS and D/C pins
|
||||
lu8g_digital_write( lu8g, U8G_PI_CS, PLATFORM_GPIO_HIGH );
|
||||
platform_gpio_mode( lu8g->u8g.pin_list[U8G_PI_CS], PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_FLOAT );
|
||||
platform_gpio_mode( lu8g->u8g.pin_list[U8G_PI_A0], PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_FLOAT );
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
lu8g_digital_write( lu8g, U8G_PI_A0, arg_val == 0 ? PLATFORM_GPIO_LOW : PLATFORM_GPIO_HIGH );
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if (arg_val == 0)
|
||||
{
|
||||
/* disable */
|
||||
lu8g_digital_write( lu8g, U8G_PI_CS, PLATFORM_GPIO_HIGH );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable */
|
||||
lu8g_digital_write( lu8g, U8G_PI_CS, PLATFORM_GPIO_LOW );
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
if ( lu8g->u8g.pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
|
||||
lu8g_digital_write( lu8g, U8G_PI_RESET, arg_val == 0 ? PLATFORM_GPIO_LOW : PLATFORM_GPIO_HIGH );
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
platform_spi_send( 1, 8, arg_val );
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
platform_spi_send( 1, 8, *ptr++ );
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_com_esp8266_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
struct _lu8g_userdata_t *lu8g = (struct _lu8g_userdata_t *)u8g;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
// we assume that the i2c bus was already initialized
|
||||
//u8g_i2c_init(u8g->pin_list[U8G_PI_I2C_OPTION]);
|
||||
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_RESET:
|
||||
/* Currently disabled, but it could be enable. Previous restrictions have been removed */
|
||||
/* u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val); */
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
lu8g->u8g.pin_list[U8G_PI_A0_STATE] = 0;
|
||||
lu8g->u8g.pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again, also forces start condition */
|
||||
if ( arg_val == 0 )
|
||||
{
|
||||
/* disable chip, send stop condition */
|
||||
platform_i2c_send_stop( ESP_I2C_ID );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* enable, do nothing: any byte writing will trigger the i2c start */
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
//u8g->pin_list[U8G_PI_SET_A0] = 1;
|
||||
if ( u8g_com_esp8266_ssd_start_sequence(lu8g) == 0 )
|
||||
return platform_i2c_send_stop( ESP_I2C_ID ), 0;
|
||||
// ignore return value -> tolerate missing ACK
|
||||
if ( platform_i2c_send_byte( ESP_I2C_ID, arg_val) == 0 )
|
||||
; //return platform_i2c_send_stop( ESP_I2C_ID ), 0;
|
||||
// platform_i2c_send_stop( ESP_I2C_ID );
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
//u8g->pin_list[U8G_PI_SET_A0] = 1;
|
||||
if ( u8g_com_esp8266_ssd_start_sequence(lu8g) == 0 )
|
||||
return platform_i2c_send_stop( ESP_I2C_ID ), 0;
|
||||
{
|
||||
register uint8_t *ptr = arg_ptr;
|
||||
while( arg_val > 0 )
|
||||
{
|
||||
// ignore return value -> tolerate missing ACK
|
||||
if ( platform_i2c_send_byte( ESP_I2C_ID, *ptr++) == 0 )
|
||||
; //return platform_i2c_send_stop( ESP_I2C_ID ), 0;
|
||||
arg_val--;
|
||||
}
|
||||
}
|
||||
// platform_i2c_send_stop( ESP_I2C_ID );
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_ADDRESS: /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
|
||||
lu8g->u8g.pin_list[U8G_PI_A0_STATE] = arg_val;
|
||||
lu8g->u8g.pin_list[U8G_PI_SET_A0] = 1; /* force a0 to set again */
|
||||
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
// Generic framebuffer device and RLE comm driver
|
||||
//
|
||||
uint8_t u8g_dev_gen_fb_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
// tell comm driver to start new framebuffer
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
static int bit_at( uint8_t *buf, int line, int x )
|
||||
{
|
||||
uint8_t byte = buf[x];
|
||||
|
||||
return buf[x] & (1 << line) ? 1 : 0;
|
||||
}
|
||||
|
||||
struct _lu8g_fbrle_item
|
||||
{
|
||||
uint8_t start_x;
|
||||
uint8_t len;
|
||||
};
|
||||
|
||||
struct _lu8g_fbrle_line
|
||||
{
|
||||
uint8_t num_valid;
|
||||
struct _lu8g_fbrle_item items[0];
|
||||
};
|
||||
|
||||
uint8_t u8g_com_esp8266_fbrle_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
struct _lu8g_userdata_t *lud = (struct _lu8g_userdata_t *)u8g;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
// allocate memory -> done
|
||||
// init buffer
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
if (arg_val == 1) {
|
||||
// new frame starts
|
||||
if (lud->cb_ref != LUA_NOREF) {
|
||||
// fire callback with nil argument
|
||||
lua_State *L = lua_getstate();
|
||||
lua_rawgeti( L, LUA_REGISTRYINDEX, lud->cb_ref );
|
||||
lua_pushnil( L );
|
||||
lua_call( L, 1, 0 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
case U8G_COM_MSG_WRITE_SEQ_P:
|
||||
{
|
||||
uint8_t xwidth = u8g->pin_list[U8G_PI_EN];
|
||||
size_t fbrle_line_size = sizeof( struct _lu8g_fbrle_line ) + sizeof( struct _lu8g_fbrle_item ) * (xwidth/2);
|
||||
int num_lines = arg_val / (xwidth/8);
|
||||
uint8_t *buf = (uint8_t *)arg_ptr;
|
||||
|
||||
struct _lu8g_fbrle_line *fbrle_line;
|
||||
if (!(fbrle_line = (struct _lu8g_fbrle_line *)c_malloc( fbrle_line_size ))) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (int line = 0; line < num_lines; line++) {
|
||||
int start_run = -1;
|
||||
fbrle_line->num_valid = 0;
|
||||
|
||||
for (int x = 0; x < xwidth; x++) {
|
||||
if (bit_at( buf, line, x ) == 0) {
|
||||
if (start_run >= 0) {
|
||||
// inside run, end it and enter result
|
||||
fbrle_line->items[fbrle_line->num_valid].start_x = start_run;
|
||||
fbrle_line->items[fbrle_line->num_valid++].len = x - start_run;
|
||||
//NODE_ERR( " line: %d x: %d len: %d\n", line, start_run, x - start_run );
|
||||
start_run = -1;
|
||||
}
|
||||
} else {
|
||||
if (start_run < 0) {
|
||||
// outside run, start it
|
||||
start_run = x;
|
||||
}
|
||||
}
|
||||
|
||||
if (fbrle_line->num_valid >= xwidth/2) break;
|
||||
}
|
||||
|
||||
// active run?
|
||||
if (start_run >= 0 && fbrle_line->num_valid < xwidth/2) {
|
||||
fbrle_line->items[fbrle_line->num_valid].start_x = start_run;
|
||||
fbrle_line->items[fbrle_line->num_valid++].len = xwidth - start_run;
|
||||
}
|
||||
|
||||
// line done, trigger callback
|
||||
if (lud->cb_ref != LUA_NOREF) {
|
||||
lua_State *L = lua_getstate();
|
||||
|
||||
lua_rawgeti( L, LUA_REGISTRYINDEX, lud->cb_ref );
|
||||
lua_pushlstring( L, (const char *)fbrle_line, fbrle_line_size );
|
||||
lua_call( L, 1, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
c_free( fbrle_line );
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
|
||||
#ifndef _U8G_GLUE_H_
|
||||
#define _U8G_GLUE_H_
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
struct _lu8g_userdata_t
|
||||
{
|
||||
u8g_t u8g;
|
||||
uint8_t i2c_addr;
|
||||
uint8_t use_delay;
|
||||
int cb_ref;
|
||||
};
|
||||
typedef struct _lu8g_userdata_t lu8g_userdata_t;
|
||||
|
||||
// shorthand macro for the u8g structure inside the userdata
|
||||
#define LU8G (&(lud->u8g))
|
||||
|
||||
uint8_t u8g_com_esp8266_fbrle_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr);
|
||||
uint8_t u8g_dev_gen_fb_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
#endif
|
@ -43,6 +43,7 @@ INCLUDES += -I ./
|
||||
INCLUDES += -I ../spiffs
|
||||
INCLUDES += -I ../libc
|
||||
INCLUDES += -I ../lua
|
||||
INCLUDES += -I ../u8g2lib/u8g2/src/clib
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
||||
|
283
app/platform/u8x8_nodemcu_hal.c
Normal file
283
app/platform/u8x8_nodemcu_hal.c
Normal file
@ -0,0 +1,283 @@
|
||||
|
||||
#include <string.h>
|
||||
#include "c_stdlib.h"
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#define U8X8_USE_PINS
|
||||
#include "u8x8_nodemcu_hal.h"
|
||||
|
||||
|
||||
uint8_t u8x8_gpio_and_delay_nodemcu(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint32_t temp;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_GPIO_AND_DELAY_INIT: // called once during init phase of u8g2/u8x8
|
||||
// can be used to setup pins
|
||||
for (int idx = 0; idx < U8X8_PIN_OUTPUT_CNT; idx++) {
|
||||
if (u8x8->pins[idx] != U8X8_PIN_NONE) {
|
||||
// configure pin as output
|
||||
if (idx == U8X8_PIN_I2C_CLOCK || idx == U8X8_PIN_I2C_DATA) {
|
||||
platform_gpio_mode( u8x8->pins[idx], PLATFORM_GPIO_OPENDRAIN, PLATFORM_GPIO_PULLUP );
|
||||
} else {
|
||||
platform_gpio_mode( u8x8->pins[idx], PLATFORM_GPIO_OUTPUT, PLATFORM_GPIO_FLOAT );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case U8X8_MSG_DELAY_NANO: // delay arg_int * 1 nano second
|
||||
os_delay_us( 1 );
|
||||
break;
|
||||
|
||||
case U8X8_MSG_DELAY_100NANO: // delay arg_int * 100 nano seconds
|
||||
temp = arg_int * 100;
|
||||
temp /= 1000;
|
||||
os_delay_us( temp > 0 ? temp : 1 );
|
||||
break;
|
||||
|
||||
case U8X8_MSG_DELAY_10MICRO: // delay arg_int * 10 micro seconds
|
||||
os_delay_us( arg_int * 10 );
|
||||
break;
|
||||
|
||||
case U8X8_MSG_DELAY_MILLI: // delay arg_int * 1 milli second
|
||||
os_delay_us( arg_int * 1000 );
|
||||
break;
|
||||
|
||||
case U8X8_MSG_DELAY_I2C: // arg_int is the I2C speed in 100KHz, e.g. 4 = 400 KHz
|
||||
temp = 5000 / arg_int; // arg_int=1: delay by 5us, arg_int = 4: delay by 1.25us
|
||||
temp /= 1000;
|
||||
os_delay_us( temp > 0 ? temp : 1 );
|
||||
break;
|
||||
|
||||
case U8X8_MSG_GPIO_D0: // D0 or SPI clock pin: Output level in arg_int
|
||||
//case U8X8_MSG_GPIO_SPI_CLOCK:
|
||||
break;
|
||||
case U8X8_MSG_GPIO_D1: // D1 or SPI data pin: Output level in arg_int
|
||||
//case U8X8_MSG_GPIO_SPI_DATA:
|
||||
break;
|
||||
case U8X8_MSG_GPIO_D2: // D2 pin: Output level in arg_int
|
||||
break;
|
||||
case U8X8_MSG_GPIO_D3: // D3 pin: Output level in arg_int
|
||||
break;
|
||||
case U8X8_MSG_GPIO_D4: // D4 pin: Output level in arg_int
|
||||
break;
|
||||
case U8X8_MSG_GPIO_D5: // D5 pin: Output level in arg_int
|
||||
break;
|
||||
case U8X8_MSG_GPIO_D6: // D6 pin: Output level in arg_int
|
||||
break;
|
||||
case U8X8_MSG_GPIO_D7: // D7 pin: Output level in arg_int
|
||||
break;
|
||||
case U8X8_MSG_GPIO_E: // E/WR pin: Output level in arg_int
|
||||
break;
|
||||
case U8X8_MSG_GPIO_CS: // CS (chip select) pin: Output level in arg_int
|
||||
platform_gpio_write( u8x8_GetPinValue( u8x8, msg ), arg_int );
|
||||
break;
|
||||
case U8X8_MSG_GPIO_DC: // DC (data/cmd, A0, register select) pin: Output level in arg_int
|
||||
platform_gpio_write( u8x8_GetPinValue( u8x8, msg ), arg_int );
|
||||
break;
|
||||
case U8X8_MSG_GPIO_RESET: // Reset pin: Output level in arg_int
|
||||
if (u8x8_GetPinValue( u8x8, msg ) != U8X8_PIN_NONE)
|
||||
platform_gpio_write( u8x8_GetPinValue(u8x8, msg), arg_int );
|
||||
break;
|
||||
case U8X8_MSG_GPIO_CS1: // CS1 (chip select) pin: Output level in arg_int
|
||||
break;
|
||||
case U8X8_MSG_GPIO_CS2: // CS2 (chip select) pin: Output level in arg_int
|
||||
break;
|
||||
|
||||
case U8X8_MSG_GPIO_I2C_CLOCK: // arg_int=0: Output low at I2C clock pin
|
||||
// arg_int=1: Input dir with pullup high for I2C clock pin
|
||||
// for SW comm routine
|
||||
platform_gpio_write( u8x8_GetPinValue( u8x8, msg ), arg_int );
|
||||
break;
|
||||
|
||||
case U8X8_MSG_GPIO_I2C_DATA: // arg_int=0: Output low at I2C data pin
|
||||
// arg_int=1: Input dir with pullup high for I2C data pin
|
||||
// for SW comm routine
|
||||
platform_gpio_write( u8x8_GetPinValue( u8x8, msg ), arg_int );
|
||||
break;
|
||||
|
||||
case U8X8_MSG_GPIO_MENU_SELECT:
|
||||
case U8X8_MSG_GPIO_MENU_NEXT:
|
||||
case U8X8_MSG_GPIO_MENU_PREV:
|
||||
case U8X8_MSG_GPIO_MENU_HOME:
|
||||
u8x8_SetGPIOResult( u8x8, /* get menu select pin state */ 0 );
|
||||
break;
|
||||
default:
|
||||
u8x8_SetGPIOResult( u8x8, 1 ); // default return value
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// static variables containing info about the i2c link
|
||||
// TODO: move to user space in u8x8_t once available
|
||||
typedef struct {
|
||||
uint8_t id;
|
||||
} hal_i2c_t;
|
||||
|
||||
uint8_t u8x8_byte_nodemcu_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t *data;
|
||||
hal_i2c_t *hal = ((u8g2_nodemcu_t *)u8x8)->hal;
|
||||
|
||||
switch(msg) {
|
||||
case U8X8_MSG_BYTE_SEND:
|
||||
if (hal->id == 0) {
|
||||
data = (uint8_t *)arg_ptr;
|
||||
|
||||
while( arg_int > 0 ) {
|
||||
platform_i2c_send_byte( 0, *data );
|
||||
data++;
|
||||
arg_int--;
|
||||
}
|
||||
|
||||
} else {
|
||||
// invalid id
|
||||
return 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case U8X8_MSG_BYTE_INIT:
|
||||
{
|
||||
// the hal member initially contains the i2c id
|
||||
int id = (int)hal;
|
||||
if (!(hal = c_malloc( sizeof ( hal_i2c_t ) )))
|
||||
return 0;
|
||||
hal->id = id;
|
||||
((u8g2_nodemcu_t *)u8x8)->hal = hal;
|
||||
}
|
||||
break;
|
||||
|
||||
case U8X8_MSG_BYTE_SET_DC:
|
||||
break;
|
||||
|
||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
||||
if (hal->id == 0) {
|
||||
platform_i2c_send_start( 0 );
|
||||
platform_i2c_send_address( 0, u8x8_GetI2CAddress(u8x8), PLATFORM_I2C_DIRECTION_TRANSMITTER );
|
||||
|
||||
} else {
|
||||
// invalid id
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
||||
if (hal->id == 0) {
|
||||
platform_i2c_send_stop( 0 );
|
||||
|
||||
} else {
|
||||
// invalid id
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// static variables containing info about the spi link
|
||||
// TODO: move to user space in u8x8_t once available
|
||||
typedef struct {
|
||||
uint8_t host;
|
||||
//spi_device_handle_t device;
|
||||
uint8_t last_dc;
|
||||
struct {
|
||||
uint8_t *data;
|
||||
size_t size, used;
|
||||
} buffer;
|
||||
} hal_spi_t;
|
||||
|
||||
static void flush_buffer_spi( hal_spi_t *hal )
|
||||
{
|
||||
if (hal->buffer.used > 0) {
|
||||
platform_spi_blkwrite( hal->host, hal->buffer.used, hal->buffer.data );
|
||||
|
||||
hal->buffer.used = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t u8x8_byte_nodemcu_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
hal_spi_t *hal = ((u8g2_nodemcu_t *)u8x8)->hal;
|
||||
|
||||
switch(msg) {
|
||||
case U8X8_MSG_BYTE_INIT:
|
||||
{
|
||||
/* disable chipselect */
|
||||
u8x8_gpio_SetCS( u8x8, u8x8->display_info->chip_disable_level );
|
||||
|
||||
// the hal member initially contains the spi host id
|
||||
int host = (int)hal;
|
||||
if (!(hal = c_malloc( sizeof ( hal_spi_t ) )))
|
||||
return 0;
|
||||
hal->host = host;
|
||||
((u8g2_nodemcu_t *)u8x8)->hal = hal;
|
||||
|
||||
hal->last_dc = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case U8X8_MSG_BYTE_SET_DC:
|
||||
if (hal->last_dc != arg_int)
|
||||
flush_buffer_spi( hal );
|
||||
|
||||
u8x8_gpio_SetDC( u8x8, arg_int );
|
||||
hal->last_dc = arg_int;
|
||||
break;
|
||||
|
||||
case U8X8_MSG_BYTE_START_TRANSFER:
|
||||
hal->buffer.size = 256;
|
||||
if (!(hal->buffer.data = (uint8_t *)c_malloc( hal->buffer.size )))
|
||||
return 0;
|
||||
hal->buffer.used = 0;
|
||||
|
||||
u8x8_gpio_SetCS( u8x8, u8x8->display_info->chip_enable_level );
|
||||
break;
|
||||
|
||||
case U8X8_MSG_BYTE_SEND:
|
||||
if (!hal->buffer.data)
|
||||
return 0;
|
||||
|
||||
while (hal->buffer.size - hal->buffer.used < arg_int) {
|
||||
hal->buffer.size *= 2;
|
||||
uint8_t *tmp;
|
||||
if (!(tmp = (uint8_t *)c_malloc( hal->buffer.size ))) {
|
||||
c_free( hal->buffer.data );
|
||||
hal->buffer.data = NULL;
|
||||
return 0;
|
||||
}
|
||||
os_memcpy( tmp, hal->buffer.data, hal->buffer.used );
|
||||
c_free( hal->buffer.data );
|
||||
hal->buffer.data = tmp;
|
||||
}
|
||||
os_memcpy( hal->buffer.data + hal->buffer.used, arg_ptr, arg_int );
|
||||
hal->buffer.used += arg_int;
|
||||
break;
|
||||
|
||||
case U8X8_MSG_BYTE_END_TRANSFER:
|
||||
if (!hal->buffer.data)
|
||||
return 0;
|
||||
|
||||
flush_buffer_spi( hal );
|
||||
|
||||
u8x8_gpio_SetCS( u8x8, u8x8->display_info->chip_disable_level );
|
||||
|
||||
c_free( hal->buffer.data );
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
26
app/platform/u8x8_nodemcu_hal.h
Normal file
26
app/platform/u8x8_nodemcu_hal.h
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
#ifndef _U8X8_NODEMCU_HAL_H
|
||||
#define _U8X8_NODEMCU_HAL_H
|
||||
|
||||
#include "u8g2.h"
|
||||
|
||||
|
||||
// extend standard u8g2_t struct with info that's needed in the communication callbacks
|
||||
typedef struct {
|
||||
u8g2_t u8g2;
|
||||
void *hal;
|
||||
|
||||
// elements for the overlay display driver
|
||||
struct {
|
||||
u8x8_msg_cb hardware_display_cb, template_display_cb;
|
||||
int rfb_cb_ref;
|
||||
uint8_t fb_update_ongoing;
|
||||
} overlay;
|
||||
} u8g2_nodemcu_t;
|
||||
|
||||
|
||||
uint8_t u8x8_gpio_and_delay_nodemcu(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_byte_nodemcu_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
uint8_t u8x8_byte_nodemcu_spi(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr);
|
||||
|
||||
#endif /* _U8X8_NODEMCU_HAL_H */
|
@ -12,7 +12,7 @@
|
||||
# a generated lib/image xxx.a ()
|
||||
#
|
||||
ifndef PDIR
|
||||
GEN_LIBS = libu8glib.a
|
||||
GEN_LIBS = libu8g2lib.a
|
||||
endif
|
||||
|
||||
STD_CFLAGS=-std=gnu11 -Wimplicit
|
||||
@ -24,7 +24,7 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
|
||||
# makefile at its root level - these are then overridden
|
||||
# for a subtree within the makefile rooted therein
|
||||
#
|
||||
#DEFINES +=
|
||||
DEFINES += -DU8X8_USE_PINS
|
||||
|
||||
#############################################################
|
||||
# Recursion Magic - Don't touch this!!
|
||||
@ -38,9 +38,13 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
|
||||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
CSRCS := $(wildcard u8g2/src/clib/*.c *.c)
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./
|
||||
INCLUDES += -I u8g2/src/clib
|
||||
INCLUDES += -I ../libc
|
||||
INCLUDES += -I ../lua
|
||||
INCLUDES += -I ../platform
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
1
app/u8g2lib/u8g2
Submodule
1
app/u8g2lib/u8g2
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 7f2fc42af3d01fdfe2cc19320bdcfe693dd2b20d
|
184
app/u8g2lib/u8x8_d_fbrle.c
Normal file
184
app/u8g2lib/u8x8_d_fbrle.c
Normal file
@ -0,0 +1,184 @@
|
||||
|
||||
// Note: This file is intended to be shared between esp8266 and esp32 platform
|
||||
|
||||
#include "u8x8.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "u8x8_nodemcu_hal.h"
|
||||
|
||||
#include "c_stdlib.h"
|
||||
|
||||
|
||||
static const u8x8_display_info_t u8x8_fbrle_display_info =
|
||||
{
|
||||
/* chip_enable_level = */ 0,
|
||||
/* chip_disable_level = */ 1,
|
||||
|
||||
/* post_chip_enable_wait_ns = */ 0,
|
||||
/* pre_chip_disable_wait_ns = */ 0,
|
||||
/* reset_pulse_width_ms = */ 0,
|
||||
/* post_reset_wait_ms = */ 0,
|
||||
/* sda_setup_time_ns = */ 0,
|
||||
/* sck_pulse_width_ns = */ 0,
|
||||
/* sck_clock_hz = */ 0,
|
||||
/* spi_mode = */ 0,
|
||||
/* i2c_bus_clock_100kHz = */ 4,
|
||||
/* data_setup_time_ns = */ 0,
|
||||
/* write_pulse_width_ns = */ 0,
|
||||
/* tile_width = */ 16,
|
||||
/* tile_hight = */ 8,
|
||||
/* default_x_offset = */ 0,
|
||||
/* flipmode_x_offset = */ 0,
|
||||
/* pixel_width = */ 128,
|
||||
/* pixel_height = */ 64
|
||||
};
|
||||
|
||||
static int bit_at( uint8_t *buf, int line, int x )
|
||||
{
|
||||
return buf[x] & (1 << line) ? 1 : 0;
|
||||
}
|
||||
|
||||
struct fbrle_item
|
||||
{
|
||||
uint8_t start_x;
|
||||
uint8_t len;
|
||||
};
|
||||
|
||||
struct fbrle_line
|
||||
{
|
||||
uint8_t num_valid;
|
||||
struct fbrle_item items[0];
|
||||
};
|
||||
|
||||
static uint8_t u8x8_d_fbrle(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
u8g2_nodemcu_t *ext_u8g2 = (u8g2_nodemcu_t *)u8x8;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
// forward to template display driver
|
||||
return ext_u8g2->overlay.template_display_cb(u8x8, msg, arg_int, arg_ptr);
|
||||
|
||||
case U8X8_MSG_DISPLAY_INIT:
|
||||
//u8x8_d_helper_display_init(u8x8);
|
||||
ext_u8g2->overlay.fb_update_ongoing = 0;
|
||||
break;
|
||||
|
||||
case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
|
||||
case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
|
||||
break;
|
||||
|
||||
#ifdef U8X8_WITH_SET_CONTRAST
|
||||
case U8X8_MSG_DISPLAY_SET_CONTRAST:
|
||||
break;
|
||||
#endif
|
||||
|
||||
case U8X8_MSG_DISPLAY_REFRESH:
|
||||
ext_u8g2->overlay.fb_update_ongoing = 0;
|
||||
break;
|
||||
|
||||
case U8X8_MSG_DISPLAY_DRAW_TILE:
|
||||
if (ext_u8g2->overlay.fb_update_ongoing == 0) {
|
||||
// tell rfb callback that a new framebuffer starts
|
||||
if (ext_u8g2->overlay.rfb_cb_ref != LUA_NOREF) {
|
||||
// fire callback with nil argument
|
||||
lua_State *L = lua_getstate();
|
||||
lua_rawgeti( L, LUA_REGISTRYINDEX, ext_u8g2->overlay.rfb_cb_ref );
|
||||
lua_pushnil( L );
|
||||
lua_call( L, 1, 0 );
|
||||
}
|
||||
// and note ongoing framebuffer update
|
||||
ext_u8g2->overlay.fb_update_ongoing = 1;
|
||||
}
|
||||
|
||||
{
|
||||
// TODO: transport tile_y, needs structural change!
|
||||
uint8_t tile_x = ((u8x8_tile_t *)arg_ptr)->x_pos;
|
||||
tile_x *= 8;
|
||||
tile_x += u8x8->x_offset;
|
||||
uint8_t tile_w = ((u8x8_tile_t *)arg_ptr)->cnt * 8;
|
||||
|
||||
size_t fbrle_line_size = sizeof( struct fbrle_line ) + sizeof( struct fbrle_item ) * (tile_w/2);
|
||||
int num_lines = 8; /*arg_val / (xwidth/8);*/
|
||||
uint8_t *buf = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
|
||||
|
||||
struct fbrle_line *fbrle_line;
|
||||
if (!(fbrle_line = (struct fbrle_line *)c_malloc( fbrle_line_size ))) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (int line = 0; line < num_lines; line++) {
|
||||
int start_run = -1;
|
||||
fbrle_line->num_valid = 0;
|
||||
|
||||
for (int x = tile_x; x < tile_x+tile_w; x++) {
|
||||
if (bit_at( buf, line, x ) == 0) {
|
||||
if (start_run >= 0) {
|
||||
// inside run, end it and enter result
|
||||
fbrle_line->items[fbrle_line->num_valid].start_x = start_run;
|
||||
fbrle_line->items[fbrle_line->num_valid++].len = x - start_run;
|
||||
//NODE_ERR( " line: %d x: %d len: %d\n", line, start_run, x - start_run );
|
||||
start_run = -1;
|
||||
}
|
||||
} else {
|
||||
if (start_run < 0) {
|
||||
// outside run, start it
|
||||
start_run = x;
|
||||
}
|
||||
}
|
||||
|
||||
if (fbrle_line->num_valid >= tile_w/2) break;
|
||||
}
|
||||
|
||||
// active run?
|
||||
if (start_run >= 0 && fbrle_line->num_valid < tile_w/2) {
|
||||
fbrle_line->items[fbrle_line->num_valid].start_x = start_run;
|
||||
fbrle_line->items[fbrle_line->num_valid++].len = tile_w - start_run;
|
||||
}
|
||||
|
||||
// line done, trigger callback
|
||||
if (ext_u8g2->overlay.rfb_cb_ref != LUA_NOREF) {
|
||||
lua_State *L = lua_getstate();
|
||||
|
||||
lua_rawgeti( L, LUA_REGISTRYINDEX, ext_u8g2->overlay.rfb_cb_ref );
|
||||
lua_pushlstring( L, (const char *)fbrle_line, fbrle_line_size );
|
||||
lua_call( L, 1, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
c_free( fbrle_line );
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8x8_d_overlay(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
|
||||
{
|
||||
uint8_t res = 1;
|
||||
u8g2_nodemcu_t *ext_u8g2 = (u8g2_nodemcu_t *)u8x8;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8X8_MSG_DISPLAY_SETUP_MEMORY:
|
||||
// only call for hardware display
|
||||
if (ext_u8g2->overlay.hardware_display_cb)
|
||||
return ext_u8g2->overlay.hardware_display_cb(u8x8, msg, arg_int, arg_ptr);
|
||||
break;
|
||||
|
||||
default:
|
||||
// forward all messages first to hardware display and then to fbrle
|
||||
if (ext_u8g2->overlay.hardware_display_cb)
|
||||
res = ext_u8g2->overlay.hardware_display_cb(u8x8, msg, arg_int, arg_ptr);
|
||||
u8x8_d_fbrle(u8x8, msg, arg_int, arg_ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
##U8glib package
|
||||
|
||||
Ported from https://github.com/olikraus/u8glib
|
||||
|
||||
|
||||
Here is black magic with ImageMagic package for image conversion:
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
mkdir out
|
||||
|
||||
for icon in *png; do
|
||||
convert $icon -depth 1 ./out/$(basename $icon .png)_1bpp.png
|
||||
if [[ "$icon" == *"black"* ]]; then
|
||||
convert ./out/$(basename $icon .png)_1bpp.png -background white -alpha Background ./out/$(basename $icon .png)_1bpp.xbm
|
||||
else
|
||||
convert ./out/$(basename $icon .png)_1bpp.png -background black -alpha Background ./out/$(basename $icon .png)_1bpp.xbm
|
||||
fi
|
||||
cat ./out/$(basename $icon .png)_1bpp.xbm | tr '\n' ' ' | tr -d " " |sed -e s'#^.*{##g' | sed s'#,}##' |sed s'/;//' | xxd -r -p > ./out/$(basename $icon .png).xbm.mono
|
||||
done
|
||||
|
||||
rm out/*png out/*xbm
|
||||
```
|
||||
Convert all the png in the current folder and put resulting .mono to ./out
|
||||
|
||||
The convert binary is a part of ImageMagic package. You need to install it.
|
||||
|
||||
```
|
||||
sudo apt-get install imagemagick
|
||||
```
|
||||
for Debian/Ubuntu.
|
2072
app/u8glib/u8g.h
2072
app/u8glib/u8g.h
File diff suppressed because it is too large
Load Diff
@ -1,177 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_bitmap.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
void u8g_DrawHBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const uint8_t *bitmap)
|
||||
{
|
||||
while( cnt > 0 )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, x, y, 0, *bitmap);
|
||||
bitmap++;
|
||||
cnt--;
|
||||
x+=8;
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap)
|
||||
{
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
|
||||
return;
|
||||
while( h > 0 )
|
||||
{
|
||||
u8g_DrawHBitmap(u8g, x, y, cnt, bitmap);
|
||||
bitmap += cnt;
|
||||
y++;
|
||||
h--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_DrawHBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const u8g_pgm_uint8_t *bitmap)
|
||||
{
|
||||
while( cnt > 0 )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, x, y, 0, u8g_pgm_read(bitmap));
|
||||
bitmap++;
|
||||
cnt--;
|
||||
x+=8;
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
|
||||
{
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
|
||||
return;
|
||||
while( h > 0 )
|
||||
{
|
||||
u8g_DrawHBitmapP(u8g, x, y, cnt, bitmap);
|
||||
bitmap += cnt;
|
||||
y++;
|
||||
h--;
|
||||
}
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
|
||||
static void u8g_DrawHXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const uint8_t *bitmap)
|
||||
{
|
||||
uint8_t d;
|
||||
x+=7;
|
||||
while( w >= 8 )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, x, y, 2, *bitmap);
|
||||
bitmap++;
|
||||
w-= 8;
|
||||
x+=8;
|
||||
}
|
||||
if ( w > 0 )
|
||||
{
|
||||
d = *bitmap;
|
||||
x -= 7;
|
||||
do
|
||||
{
|
||||
if ( d & 1 )
|
||||
u8g_DrawPixel(u8g, x, y);
|
||||
x++;
|
||||
w--;
|
||||
d >>= 1;
|
||||
} while ( w > 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap)
|
||||
{
|
||||
u8g_uint_t b;
|
||||
b = w;
|
||||
b += 7;
|
||||
b >>= 3;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
|
||||
return;
|
||||
|
||||
while( h > 0 )
|
||||
{
|
||||
u8g_DrawHXBM(u8g, x, y, w, bitmap);
|
||||
bitmap += b;
|
||||
y++;
|
||||
h--;
|
||||
}
|
||||
}
|
||||
|
||||
static void u8g_DrawHXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const u8g_pgm_uint8_t *bitmap)
|
||||
{
|
||||
uint8_t d;
|
||||
x+=7;
|
||||
while( w >= 8 )
|
||||
{
|
||||
u8g_Draw8Pixel(u8g, x, y, 2, u8g_pgm_read(bitmap));
|
||||
bitmap++;
|
||||
w-= 8;
|
||||
x+=8;
|
||||
}
|
||||
if ( w > 0 )
|
||||
{
|
||||
d = u8g_pgm_read(bitmap);
|
||||
x -= 7;
|
||||
do
|
||||
{
|
||||
if ( d & 1 )
|
||||
u8g_DrawPixel(u8g, x, y);
|
||||
x++;
|
||||
w--;
|
||||
d >>= 1;
|
||||
} while ( w > 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
|
||||
{
|
||||
u8g_uint_t b;
|
||||
b = w;
|
||||
b += 7;
|
||||
b >>= 3;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
|
||||
return;
|
||||
while( h > 0 )
|
||||
{
|
||||
u8g_DrawHXBMP(u8g, x, y, w, bitmap);
|
||||
bitmap += b;
|
||||
y++;
|
||||
h--;
|
||||
}
|
||||
}
|
@ -1,382 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_circle.c
|
||||
|
||||
Utility to draw empty and filled circles.
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, bjthom@gmail.com
|
||||
u8g_DrawCircle & u8g_DrawDisc by 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.
|
||||
|
||||
Addition to the U8G Library 02/25/12
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#ifdef OLD_CODE
|
||||
|
||||
void circ_upperRight(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
|
||||
u8g_DrawPixel(u8g, x0 + x, y0 - y);
|
||||
u8g_DrawPixel(u8g, x0 + y, y0 - x);
|
||||
}
|
||||
|
||||
void circ_upperLeft(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
|
||||
u8g_DrawPixel(u8g, x0 - x, y0 - y);
|
||||
u8g_DrawPixel(u8g, x0 - y, y0 - x);
|
||||
}
|
||||
|
||||
void circ_lowerRight(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
|
||||
u8g_DrawPixel(u8g, x0 + x, y0 + y);
|
||||
u8g_DrawPixel(u8g, x0 + y, y0 + x);
|
||||
}
|
||||
|
||||
void circ_lowerLeft(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
|
||||
u8g_DrawPixel(u8g, x0 - x, y0 + y);
|
||||
u8g_DrawPixel(u8g, x0 - y, y0 + x);
|
||||
}
|
||||
|
||||
void circ_all(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
|
||||
circ_upperRight(u8g, x, y, x0, y0);
|
||||
circ_upperLeft(u8g, x, y, x0, y0);
|
||||
circ_lowerRight(u8g, x, y, x0, y0);
|
||||
circ_lowerLeft(u8g, x, y, x0, y0);
|
||||
}
|
||||
|
||||
void u8g_DrawEmpCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
if ( u8g_IsBBXIntersection(u8g, x0-rad-1, y0-rad-1, 2*rad+1, 2*rad+1) == 0)
|
||||
return;
|
||||
|
||||
int f = 1 - rad;
|
||||
int ddF_x = 1;
|
||||
int ddF_y = -2*rad;
|
||||
uint8_t x = 0;
|
||||
uint8_t y = rad;
|
||||
|
||||
void ( *circ_util )(u8g_t *, u8g_uint_t, u8g_uint_t, u8g_uint_t, u8g_uint_t);
|
||||
|
||||
switch (option)
|
||||
{
|
||||
case U8G_CIRC_UPPER_RIGHT:
|
||||
u8g_DrawPixel(u8g, x0, y0 - rad);
|
||||
u8g_DrawPixel(u8g, x0 + rad, y0);
|
||||
circ_util = circ_upperRight;
|
||||
break;
|
||||
case U8G_CIRC_UPPER_LEFT:
|
||||
u8g_DrawPixel(u8g, x0, y0 - rad);
|
||||
u8g_DrawPixel(u8g, x0 - rad, y0);
|
||||
circ_util = circ_upperLeft;
|
||||
break;
|
||||
case U8G_CIRC_LOWER_RIGHT:
|
||||
u8g_DrawPixel(u8g, x0, y0 + rad);
|
||||
u8g_DrawPixel(u8g, x0 + rad, y0);
|
||||
circ_util = circ_lowerRight;
|
||||
break;
|
||||
case U8G_CIRC_LOWER_LEFT:
|
||||
u8g_DrawPixel(u8g, x0, y0 + rad);
|
||||
u8g_DrawPixel(u8g, x0 - rad, y0);
|
||||
circ_util = circ_lowerLeft;
|
||||
break;
|
||||
default:
|
||||
case U8G_CIRC_ALL:
|
||||
u8g_DrawPixel(u8g, x0, y0 + rad);
|
||||
u8g_DrawPixel(u8g, x0, y0 - rad);
|
||||
u8g_DrawPixel(u8g, x0 + rad, y0);
|
||||
u8g_DrawPixel(u8g, x0 - rad, y0);
|
||||
circ_util = circ_all;
|
||||
break;
|
||||
}
|
||||
|
||||
while( x < y )
|
||||
{
|
||||
if(f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
circ_util(u8g, x, y, x0, y0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_DrawFillCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
if ( u8g_IsBBXIntersection(u8g, x0-rad-1, y0-rad-1, 2*rad+1, 2*rad+1) == 0)
|
||||
return;
|
||||
|
||||
int f = 1 - rad;
|
||||
int ddF_x = 1;
|
||||
int ddF_y = -2*rad;
|
||||
uint8_t x = 0;
|
||||
uint8_t y = rad;
|
||||
|
||||
// Draw vertical diameter at the horiz. center
|
||||
// u8g_DrawVLine(u8g, x0, y0 - rad, 2*rad+1);
|
||||
|
||||
if (option == U8G_CIRC_UPPER_LEFT || option == U8G_CIRC_UPPER_RIGHT) {
|
||||
u8g_DrawVLine(u8g, x0, y0 - rad, rad+1);
|
||||
}
|
||||
else if (option == U8G_CIRC_LOWER_LEFT || option == U8G_CIRC_LOWER_RIGHT) {
|
||||
u8g_DrawVLine(u8g, x0, y0, rad+1);
|
||||
}
|
||||
else {
|
||||
u8g_DrawVLine(u8g, x0, y0 - rad, 2*rad+1);
|
||||
}
|
||||
|
||||
while( x < y )
|
||||
{
|
||||
if(f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
//Draw vertical lines from one point to another
|
||||
|
||||
switch (option)
|
||||
{
|
||||
case U8G_CIRC_UPPER_RIGHT:
|
||||
u8g_DrawVLine(u8g, x0+x, y0-y, y+1);
|
||||
u8g_DrawVLine(u8g, x0+y, y0-x, x+1);
|
||||
break;
|
||||
case U8G_CIRC_UPPER_LEFT:
|
||||
u8g_DrawVLine(u8g, x0-x, y0-y, y+1);
|
||||
u8g_DrawVLine(u8g, x0-y, y0-x, x+1);
|
||||
break;
|
||||
case U8G_CIRC_LOWER_RIGHT:
|
||||
u8g_DrawVLine(u8g, x0+x, y0, y+1);
|
||||
u8g_DrawVLine(u8g, x0+y, y0, x+1);
|
||||
break;
|
||||
case U8G_CIRC_LOWER_LEFT:
|
||||
u8g_DrawVLine(u8g, x0-x, y0, y+1);
|
||||
u8g_DrawVLine(u8g, x0-y, y0, x+1);
|
||||
break;
|
||||
case U8G_CIRC_ALL:
|
||||
u8g_DrawVLine(u8g, x0+x, y0-y, 2*y+1);
|
||||
u8g_DrawVLine(u8g, x0-x, y0-y, 2*y+1);
|
||||
u8g_DrawVLine(u8g, x0+y, y0-x, 2*x+1);
|
||||
u8g_DrawVLine(u8g, x0-y, y0-x, 2*x+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*=========================================================================*/
|
||||
|
||||
static void u8g_draw_circle_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option) U8G_NOINLINE;
|
||||
|
||||
static void u8g_draw_circle_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option)
|
||||
{
|
||||
/* upper right */
|
||||
if ( option & U8G_DRAW_UPPER_RIGHT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 + x, y0 - y);
|
||||
u8g_DrawPixel(u8g, x0 + y, y0 - x);
|
||||
}
|
||||
|
||||
/* upper left */
|
||||
if ( option & U8G_DRAW_UPPER_LEFT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 - x, y0 - y);
|
||||
u8g_DrawPixel(u8g, x0 - y, y0 - x);
|
||||
}
|
||||
|
||||
/* lower right */
|
||||
if ( option & U8G_DRAW_LOWER_RIGHT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 + x, y0 + y);
|
||||
u8g_DrawPixel(u8g, x0 + y, y0 + x);
|
||||
}
|
||||
|
||||
/* lower left */
|
||||
if ( option & U8G_DRAW_LOWER_LEFT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 - x, y0 + y);
|
||||
u8g_DrawPixel(u8g, x0 - y, y0 + x);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_draw_circle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
u8g_int_t f;
|
||||
u8g_int_t ddF_x;
|
||||
u8g_int_t ddF_y;
|
||||
u8g_uint_t x;
|
||||
u8g_uint_t y;
|
||||
|
||||
f = 1;
|
||||
f -= rad;
|
||||
ddF_x = 1;
|
||||
ddF_y = 0;
|
||||
ddF_y -= rad;
|
||||
ddF_y *= 2;
|
||||
x = 0;
|
||||
y = rad;
|
||||
|
||||
u8g_draw_circle_section(u8g, x, y, x0, y0, option);
|
||||
|
||||
while ( x < y )
|
||||
{
|
||||
if (f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
u8g_draw_circle_section(u8g, x, y, x0, y0, option);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawCircle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
/* check for bounding box */
|
||||
{
|
||||
u8g_uint_t radp, radp2;
|
||||
|
||||
radp = rad;
|
||||
radp++;
|
||||
radp2 = radp;
|
||||
radp2 *= 2;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x0-radp, y0-radp, radp2, radp2) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/* draw circle */
|
||||
u8g_draw_circle(u8g, x0, y0, rad, option);
|
||||
}
|
||||
|
||||
static void u8g_draw_disc_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option) U8G_NOINLINE;
|
||||
|
||||
static void u8g_draw_disc_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option)
|
||||
{
|
||||
/* upper right */
|
||||
if ( option & U8G_DRAW_UPPER_RIGHT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0+x, y0-y, y+1);
|
||||
u8g_DrawVLine(u8g, x0+y, y0-x, x+1);
|
||||
}
|
||||
|
||||
/* upper left */
|
||||
if ( option & U8G_DRAW_UPPER_LEFT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0-x, y0-y, y+1);
|
||||
u8g_DrawVLine(u8g, x0-y, y0-x, x+1);
|
||||
}
|
||||
|
||||
/* lower right */
|
||||
if ( option & U8G_DRAW_LOWER_RIGHT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0+x, y0, y+1);
|
||||
u8g_DrawVLine(u8g, x0+y, y0, x+1);
|
||||
}
|
||||
|
||||
/* lower left */
|
||||
if ( option & U8G_DRAW_LOWER_LEFT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0-x, y0, y+1);
|
||||
u8g_DrawVLine(u8g, x0-y, y0, x+1);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_draw_disc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
u8g_int_t f;
|
||||
u8g_int_t ddF_x;
|
||||
u8g_int_t ddF_y;
|
||||
u8g_uint_t x;
|
||||
u8g_uint_t y;
|
||||
|
||||
f = 1;
|
||||
f -= rad;
|
||||
ddF_x = 1;
|
||||
ddF_y = 0;
|
||||
ddF_y -= rad;
|
||||
ddF_y *= 2;
|
||||
x = 0;
|
||||
y = rad;
|
||||
|
||||
u8g_draw_disc_section(u8g, x, y, x0, y0, option);
|
||||
|
||||
while ( x < y )
|
||||
{
|
||||
if (f >= 0)
|
||||
{
|
||||
y--;
|
||||
ddF_y += 2;
|
||||
f += ddF_y;
|
||||
}
|
||||
x++;
|
||||
ddF_x += 2;
|
||||
f += ddF_x;
|
||||
|
||||
u8g_draw_disc_section(u8g, x, y, x0, y0, option);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawDisc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
|
||||
{
|
||||
/* check for bounding box */
|
||||
{
|
||||
u8g_uint_t radp, radp2;
|
||||
|
||||
radp = rad;
|
||||
radp++;
|
||||
radp2 = radp;
|
||||
radp2 *= 2;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x0-radp, y0-radp, radp2, radp2) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/* draw disc */
|
||||
u8g_draw_disc(u8g, x0, y0, rad, option);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,156 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_clip.c
|
||||
|
||||
procedures for clipping
|
||||
taken over from procs in u8g_pb.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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.
|
||||
|
||||
Notes
|
||||
|
||||
This is one of the most critical parts of u8glib. It must be fast, but still reliable.
|
||||
Based on the intersection program (see tools folder), there is minimized version of
|
||||
the condition for the intersaction test:
|
||||
minimized version
|
||||
---1----0 1 b1 <= a2 && b1 > b2
|
||||
-----1--0 1 b2 >= a1 && b1 > b2
|
||||
---1-1--- 1 b1 <= a2 && b2 >= a1
|
||||
It includes the assumption, that a1 <= a2 is always true (correct, because
|
||||
a1, a2 are the page dimensions.
|
||||
|
||||
The direct implementation of the above result is done in:
|
||||
uint8_t u8g_is_intersection_boolean(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
|
||||
However, this is slower than a decision tree version:
|
||||
static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
|
||||
Also suprising is, that the macro implementation is slower than the inlined version.
|
||||
|
||||
The decision tree is based on the expansion of the truth table.
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define U8G_ALWAYS_INLINE __inline__ __attribute__((always_inline))
|
||||
#else
|
||||
#define U8G_ALWAYS_INLINE
|
||||
#endif
|
||||
|
||||
/*
|
||||
intersection assumptions:
|
||||
a1 <= a2 is always true
|
||||
|
||||
minimized version
|
||||
---1----0 1 b1 <= a2 && b1 > b2
|
||||
-----1--0 1 b2 >= a1 && b1 > b2
|
||||
---1-1--- 1 b1 <= a2 && b2 >= a1
|
||||
*/
|
||||
|
||||
#ifdef OLD_CODE_WHICH_IS_TOO_SLOW
|
||||
static uint8_t u8g_is_intersection_boolean(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
|
||||
{
|
||||
uint8_t c1, c2, c3, tmp;
|
||||
c1 = v0 <= a1;
|
||||
c2 = v1 >= a0;
|
||||
c3 = v0 > v1;
|
||||
|
||||
tmp = c1;
|
||||
c1 &= c2;
|
||||
c2 &= c3;
|
||||
c3 &= tmp;
|
||||
c1 |= c2;
|
||||
c1 |= c3;
|
||||
return c1 & 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define U8G_IS_INTERSECTION_MACRO(a0,a1,v0,v1) ((uint8_t)( (v0) <= (a1) ) ? ( ( (v1) >= (a0) ) ? ( 1 ) : ( (v0) > (v1) ) ) : ( ( (v1) >= (a0) ) ? ( (v0) > (v1) ) : ( 0 ) ))
|
||||
|
||||
//static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1) U8G_ALWAYS_INLINE;
|
||||
static uint8_t U8G_ALWAYS_INLINE u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
|
||||
{
|
||||
/* surprisingly the macro leads to larger code */
|
||||
/* return U8G_IS_INTERSECTION_MACRO(a0,a1,v0,v1); */
|
||||
if ( v0 <= a1 )
|
||||
{
|
||||
if ( v1 >= a0 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( v0 > v1 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( v1 >= a0 )
|
||||
{
|
||||
if ( v0 > v1 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
|
||||
{
|
||||
register u8g_uint_t tmp;
|
||||
tmp = y;
|
||||
tmp += h;
|
||||
tmp--;
|
||||
if ( u8g_is_intersection_decision_tree(u8g->current_page.y0, u8g->current_page.y1, y, tmp) == 0 )
|
||||
return 0;
|
||||
|
||||
tmp = x;
|
||||
tmp += w;
|
||||
tmp--;
|
||||
return u8g_is_intersection_decision_tree(u8g->current_page.x0, u8g->current_page.x1, x, tmp);
|
||||
}
|
||||
|
||||
|
@ -1,173 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_com_api.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
uint8_t u8g_InitCom(u8g_t *u8g, u8g_dev_t *dev, uint8_t clk_cycle_time)
|
||||
{
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_INIT, clk_cycle_time, NULL);
|
||||
}
|
||||
|
||||
void u8g_StopCom(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
dev->com_fn(u8g, U8G_COM_MSG_STOP, 0, NULL);
|
||||
}
|
||||
|
||||
/* cs contains the chip number, which should be enabled */
|
||||
void u8g_SetChipSelect(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs)
|
||||
{
|
||||
dev->com_fn(u8g, U8G_COM_MSG_CHIP_SELECT, cs, NULL);
|
||||
}
|
||||
|
||||
void u8g_SetResetLow(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
dev->com_fn(u8g, U8G_COM_MSG_RESET, 0, NULL);
|
||||
}
|
||||
|
||||
void u8g_SetResetHigh(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
dev->com_fn(u8g, U8G_COM_MSG_RESET, 1, NULL);
|
||||
}
|
||||
|
||||
|
||||
void u8g_SetAddress(u8g_t *u8g, u8g_dev_t *dev, uint8_t address)
|
||||
{
|
||||
dev->com_fn(u8g, U8G_COM_MSG_ADDRESS, address, NULL);
|
||||
}
|
||||
|
||||
uint8_t u8g_WriteByte(u8g_t *u8g, u8g_dev_t *dev, uint8_t val)
|
||||
{
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_WRITE_BYTE, val, NULL);
|
||||
}
|
||||
|
||||
uint8_t u8g_WriteSequence(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *seq)
|
||||
{
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ, cnt, seq);
|
||||
}
|
||||
|
||||
uint8_t u8g_WriteSequenceP(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, const uint8_t *seq)
|
||||
{
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ_P, cnt, (void *)seq);
|
||||
}
|
||||
|
||||
/*
|
||||
sequence := { direct_value | escape_sequence }
|
||||
direct_value := 0..254
|
||||
escape_sequence := value_255 | sequence_end | delay | adr | cs | not_used
|
||||
value_255 := 255 255
|
||||
sequence_end = 255 254
|
||||
delay := 255 0..127
|
||||
adr := 255 0x0e0 .. 0x0ef
|
||||
cs := 255 0x0d0 .. 0x0df
|
||||
not_used := 255 101..254
|
||||
|
||||
#define U8G_ESC_DLY(x) 255, ((x) & 0x7f)
|
||||
#define U8G_ESC_CS(x) 255, (0xd0 | ((x)&0x0f))
|
||||
#define U8G_ESC_ADR(x) 255, (0xe0 | ((x)&0x0f))
|
||||
#define U8G_ESC_VCC(x) 255, (0xbe | ((x)&0x01))
|
||||
#define U8G_ESC_END 255, 254
|
||||
#define U8G_ESC_255 255, 255
|
||||
#define U8G_ESC_RST(x) 255, (0xc0 | ((x)&0x0f))
|
||||
|
||||
*/
|
||||
uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq)
|
||||
{
|
||||
uint8_t is_escape = 0;
|
||||
uint8_t value;
|
||||
for(;;)
|
||||
{
|
||||
value = u8g_pgm_read(esc_seq);
|
||||
if ( is_escape == 0 )
|
||||
{
|
||||
if ( value != 255 )
|
||||
{
|
||||
if ( u8g_WriteByte(u8g, dev, value) == 0 )
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_escape = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( value == 255 )
|
||||
{
|
||||
if ( u8g_WriteByte(u8g, dev, value) == 0 )
|
||||
return 0;
|
||||
}
|
||||
else if ( value == 254 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if ( value >= 0x0f0 )
|
||||
{
|
||||
/* not yet used, do nothing */
|
||||
}
|
||||
else if ( value >= 0xe0 )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, value & 0x0f);
|
||||
}
|
||||
else if ( value >= 0xd0 )
|
||||
{
|
||||
u8g_SetChipSelect(u8g, dev, value & 0x0f);
|
||||
}
|
||||
else if ( value >= 0xc0 )
|
||||
{
|
||||
u8g_SetResetLow(u8g, dev);
|
||||
value &= 0x0f;
|
||||
value <<= 4;
|
||||
value+=2;
|
||||
u8g_Delay(u8g, value);
|
||||
u8g_SetResetHigh(u8g, dev);
|
||||
u8g_Delay(u8g, value);
|
||||
}
|
||||
else if ( value >= 0xbe )
|
||||
{
|
||||
/* not yet implemented */
|
||||
/* u8g_SetVCC(u8g, dev, value & 0x01); */
|
||||
}
|
||||
else if ( value <= 127 )
|
||||
{
|
||||
u8g_Delay(u8g, value);
|
||||
}
|
||||
is_escape = 0;
|
||||
}
|
||||
esc_seq++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,94 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_com_api_16gr.c
|
||||
|
||||
Extension of the com api for devices with 16 graylevels (4 bit per pixel).
|
||||
This should fit to the 8h and 16h architectures (pb8v1, pb8v2, pb16v1, pb16v2),
|
||||
mainly intended for SSD OLEDs
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
/* interpret b as a monochrome bit pattern, write value 15 for high bit and value 0 for a low bit */
|
||||
/* topbit (msb) is sent last */
|
||||
/* example: b = 0x083 will send 0xff, 0x00, 0x00, 0xf0 */
|
||||
uint8_t u8g_WriteByteBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b)
|
||||
{
|
||||
static uint8_t buf[4];
|
||||
static uint8_t map[4] = { 0, 0x00f, 0x0f0, 0x0ff };
|
||||
buf [3] = map[b & 3];
|
||||
b>>=2;
|
||||
buf [2] = map[b & 3];
|
||||
b>>=2;
|
||||
buf [1] = map[b & 3];
|
||||
b>>=2;
|
||||
buf [0] = map[b & 3];
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ, 4, buf);
|
||||
}
|
||||
|
||||
uint8_t u8g_WriteSequenceBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr)
|
||||
{
|
||||
do
|
||||
{
|
||||
if ( u8g_WriteByteBWTo16GrDevice(u8g, dev, *ptr++) == 0 )
|
||||
return 0;
|
||||
cnt--;
|
||||
} while( cnt != 0 );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* interpret b as a 4L bit pattern, write values 0x000, 0x004, 0x008, 0x00c */
|
||||
uint8_t u8g_WriteByte4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b)
|
||||
{
|
||||
//static uint8_t map[16] = { 0x000, 0x004, 0x008, 0x00c, 0x040, 0x044, 0x048, 0x04c, 0x080, 0x084, 0x088, 0x08c, 0x0c0, 0x0c4, 0x0c8, 0x0cc};
|
||||
//static uint8_t map[16] = { 0x000, 0x004, 0x00a, 0x00f, 0x040, 0x044, 0x04a, 0x04f, 0x0a0, 0x0a4, 0x0aa, 0x0af, 0x0f0, 0x0f4, 0x0fa, 0x0ff};
|
||||
static uint8_t map[16] = { 0x000, 0x040, 0x0a0, 0x0f0, 0x004, 0x044, 0x0a4, 0x0f4, 0x00a, 0x04a, 0x0aa, 0x0fa, 0x00f, 0x04f, 0x0af, 0x0ff};
|
||||
uint8_t bb;
|
||||
bb = b;
|
||||
bb &= 15;
|
||||
b>>=4;
|
||||
dev->com_fn(u8g, U8G_COM_MSG_WRITE_BYTE, map[bb], NULL);
|
||||
return dev->com_fn(u8g, U8G_COM_MSG_WRITE_BYTE, map[b], NULL);
|
||||
}
|
||||
|
||||
uint8_t u8g_WriteSequence4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr)
|
||||
{
|
||||
do
|
||||
{
|
||||
if ( u8g_WriteByte4LTo16GrDevice(u8g, dev, *ptr++) == 0 )
|
||||
return 0;
|
||||
cnt--;
|
||||
} while( cnt != 0 );
|
||||
return 1;
|
||||
}
|
@ -1,643 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_com_i2c.c
|
||||
|
||||
generic i2c interface
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
//#define U8G_I2C_WITH_NO_ACK
|
||||
|
||||
static uint8_t u8g_i2c_err_code;
|
||||
static uint8_t u8g_i2c_opt; /* U8G_I2C_OPT_NO_ACK, SAM: U8G_I2C_OPT_DEV_1 */
|
||||
/*
|
||||
position values
|
||||
1: start condition
|
||||
2: sla transfer
|
||||
*/
|
||||
static uint8_t u8g_i2c_err_pos;
|
||||
|
||||
|
||||
void u8g_i2c_clear_error(void)
|
||||
{
|
||||
u8g_i2c_err_code = U8G_I2C_ERR_NONE;
|
||||
u8g_i2c_err_pos = 0;
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_get_error(void)
|
||||
{
|
||||
return u8g_i2c_err_code;
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_get_err_pos(void)
|
||||
{
|
||||
return u8g_i2c_err_pos;
|
||||
}
|
||||
|
||||
|
||||
#if defined(__AVR_XMEGA__)
|
||||
#elif defined(__AVR__)
|
||||
|
||||
static void u8g_i2c_set_error(uint8_t code, uint8_t pos)
|
||||
{
|
||||
if ( u8g_i2c_err_code > 0 )
|
||||
return;
|
||||
u8g_i2c_err_code |= code;
|
||||
u8g_i2c_err_pos = pos;
|
||||
}
|
||||
|
||||
#define U8G_ATMEGA_HW_TWI
|
||||
|
||||
/* remove the definition for attiny */
|
||||
#if __AVR_ARCH__ == 2
|
||||
#undef U8G_ATMEGA_HW_TWI
|
||||
#endif
|
||||
#if __AVR_ARCH__ == 25
|
||||
#undef U8G_ATMEGA_HW_TWI
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(U8G_ATMEGA_HW_TWI)
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <util/twi.h>
|
||||
|
||||
|
||||
|
||||
void u8g_i2c_init(uint8_t options)
|
||||
{
|
||||
/*
|
||||
TWBR: bit rate register
|
||||
TWSR: status register (contains preselector bits)
|
||||
|
||||
prescalar
|
||||
0 1
|
||||
1 4
|
||||
2 16
|
||||
3 64
|
||||
|
||||
f = F_CPU/(16+2*TWBR*prescalar)
|
||||
|
||||
F_CPU = 16MHz
|
||||
TWBR = 152;
|
||||
TWSR = 0;
|
||||
--> 50KHz
|
||||
|
||||
TWBR = 72;
|
||||
TWSR = 0;
|
||||
--> 100KHz
|
||||
|
||||
TWBR = 12;
|
||||
TWSR = 0;
|
||||
--> 400KHz
|
||||
|
||||
F_CPU/(2*100000)-8 --> calculate TWBR value for 100KHz
|
||||
*/
|
||||
u8g_i2c_opt = options;
|
||||
TWSR = 0;
|
||||
if ( options & U8G_I2C_OPT_FAST )
|
||||
{
|
||||
TWBR = F_CPU/(2*400000)-8;
|
||||
}
|
||||
else
|
||||
{
|
||||
TWBR = F_CPU/(2*100000)-8;
|
||||
}
|
||||
u8g_i2c_clear_error();
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos)
|
||||
{
|
||||
volatile uint16_t cnt = 2000; /* timout value should be > 280 for 50KHz Bus and 16 Mhz CPU, however the start condition might need longer */
|
||||
while( !(TWCR & mask) )
|
||||
{
|
||||
if ( cnt == 0 )
|
||||
{
|
||||
if ( u8g_i2c_opt & U8G_I2C_OPT_NO_ACK )
|
||||
{
|
||||
return 1; /* all ok */
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g_i2c_set_error(U8G_I2C_ERR_TIMEOUT, pos);
|
||||
return 0; /* error */
|
||||
}
|
||||
}
|
||||
cnt--;
|
||||
}
|
||||
return 1; /* all ok */
|
||||
}
|
||||
|
||||
/* sla includes all 8 bits (with r/w bit), assums master transmit */
|
||||
uint8_t u8g_i2c_start(uint8_t sla)
|
||||
{
|
||||
register uint8_t status;
|
||||
|
||||
/* send start */
|
||||
TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN);
|
||||
|
||||
/* wait */
|
||||
if ( u8g_i2c_wait(_BV(TWINT), 1) == 0 )
|
||||
return 0;
|
||||
|
||||
status = TW_STATUS;
|
||||
|
||||
/* check status after start */
|
||||
if ( status != TW_START && status != TW_REP_START )
|
||||
{
|
||||
u8g_i2c_set_error(U8G_I2C_ERR_BUS, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* set slave address */
|
||||
TWDR = sla;
|
||||
|
||||
/* enable sla transfer */
|
||||
TWCR = _BV(TWINT) | _BV(TWEN);
|
||||
|
||||
/* wait */
|
||||
if ( u8g_i2c_wait(_BV(TWINT), 2) == 0 )
|
||||
return 0;
|
||||
|
||||
if ( u8g_i2c_opt & U8G_I2C_OPT_NO_ACK )
|
||||
{
|
||||
/* do not check for ACK */
|
||||
}
|
||||
else
|
||||
{
|
||||
status = TW_STATUS;
|
||||
/* check status after sla */
|
||||
if ( status != TW_MT_SLA_ACK )
|
||||
{
|
||||
u8g_i2c_set_error(U8G_I2C_ERR_BUS, 2);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_send_byte(uint8_t data)
|
||||
{
|
||||
register uint8_t status;
|
||||
TWDR = data;
|
||||
TWCR = _BV(TWINT) | _BV(TWEN);
|
||||
if ( u8g_i2c_wait(_BV(TWINT), 3) == 0 )
|
||||
return 0;
|
||||
|
||||
if ( u8g_i2c_opt & U8G_I2C_OPT_NO_ACK )
|
||||
{
|
||||
/* do not check for ACK */
|
||||
}
|
||||
else
|
||||
{
|
||||
status = TW_STATUS;
|
||||
if ( status != TW_MT_DATA_ACK )
|
||||
{
|
||||
u8g_i2c_set_error(U8G_I2C_ERR_BUS, 3);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void u8g_i2c_stop(void)
|
||||
{
|
||||
/* write stop */
|
||||
TWCR = _BV(TWINT) | _BV(TWEN) | _BV(TWSTO);
|
||||
|
||||
/* no error is checked for the stop condition */
|
||||
u8g_i2c_wait(_BV(TWSTO), 4);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void twi_send(uint8_t adr, uint8_t data1, uint8_t data2)
|
||||
{
|
||||
u8g_i2c_start(adr<<1);
|
||||
u8g_i2c_send_byte(data1);
|
||||
u8g_i2c_send_byte(data2);
|
||||
u8g_i2c_stop();
|
||||
}
|
||||
*/
|
||||
|
||||
#elif defined(ARDUINO) && defined(__SAM3X8E__)
|
||||
/* Arduino Due */
|
||||
#include "Arduino.h"
|
||||
#include "sam.h"
|
||||
|
||||
/*
|
||||
|
||||
Controller
|
||||
|
||||
TWI0 TWCK0 PA18 A DUE PCB: SCL1
|
||||
TWI0 TWD0 PA17 A DUE PCB: SDA1
|
||||
TWI1 TWCK1 PB13 A DUE PCB: SCL 21
|
||||
TWI1 TWD1 PB12 A DUE PCB: SDA 20
|
||||
|
||||
Arduino definitions
|
||||
|
||||
#define PIN_WIRE_SDA (20u)
|
||||
#define PIN_WIRE_SCL (21u)
|
||||
#define WIRE_INTERFACE TWI1
|
||||
#define WIRE_INTERFACE_ID ID_TWI1
|
||||
#define WIRE_ISR_HANDLER TWI1_Handler
|
||||
|
||||
#define PIN_WIRE1_SDA (70u)
|
||||
#define PIN_WIRE1_SCL (71u)
|
||||
#define WIRE1_INTERFACE TWI0
|
||||
#define WIRE1_INTERFACE_ID ID_TWI0
|
||||
#define WIRE1_ISR_HANDLER TWI0_Handler
|
||||
|
||||
|
||||
*/
|
||||
|
||||
static void i2c_400KHz_delay(void)
|
||||
{
|
||||
/* should be at least 4 */
|
||||
/* should be 5 for 100KHz transfer speed */
|
||||
|
||||
|
||||
/*
|
||||
Arduino Due
|
||||
0x NOP: 470KHz
|
||||
4x NOP: 450KHz
|
||||
8x NOP: 430KHz
|
||||
16x NOP: 400KHz
|
||||
*/
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
}
|
||||
|
||||
static void i2c_100KHz_delay(void)
|
||||
{
|
||||
/*
|
||||
1x u8g_MicroDelay() ca. 130KHz
|
||||
2x u8g_MicroDelay() ca. 80KHz
|
||||
*/
|
||||
u8g_MicroDelay();
|
||||
u8g_MicroDelay();
|
||||
}
|
||||
|
||||
|
||||
uint32_t i2c_started = 0;
|
||||
uint32_t i2c_scl_pin = 0;
|
||||
uint32_t i2c_sda_pin = 0;
|
||||
void (*i2c_delay)(void) = i2c_100KHz_delay;
|
||||
|
||||
const PinDescription *i2c_scl_pin_desc;
|
||||
const PinDescription *i2c_sda_pin_desc;
|
||||
|
||||
|
||||
/* maybe this can be optimized */
|
||||
static void i2c_init(void)
|
||||
{
|
||||
i2c_sda_pin_desc = &(g_APinDescription[i2c_sda_pin]);
|
||||
i2c_scl_pin_desc = &(g_APinDescription[i2c_scl_pin]);
|
||||
pinMode(i2c_sda_pin, OUTPUT);
|
||||
digitalWrite(i2c_sda_pin, HIGH);
|
||||
pinMode(i2c_scl_pin, OUTPUT);
|
||||
digitalWrite(i2c_scl_pin, HIGH);
|
||||
PIO_Configure( i2c_sda_pin_desc->pPort, PIO_OUTPUT_0, i2c_sda_pin_desc->ulPin, PIO_OPENDRAIN );
|
||||
PIO_Configure( i2c_scl_pin_desc->pPort, PIO_OUTPUT_0, i2c_scl_pin_desc->ulPin, PIO_OPENDRAIN );
|
||||
PIO_Clear( i2c_sda_pin_desc->pPort, i2c_sda_pin_desc->ulPin) ;
|
||||
PIO_Clear( i2c_scl_pin_desc->pPort, i2c_scl_pin_desc->ulPin) ;
|
||||
PIO_Configure( i2c_sda_pin_desc->pPort, PIO_INPUT, i2c_sda_pin_desc->ulPin, PIO_DEFAULT ) ;
|
||||
PIO_Configure( i2c_scl_pin_desc->pPort, PIO_INPUT, i2c_scl_pin_desc->ulPin, PIO_DEFAULT ) ;
|
||||
i2c_delay();
|
||||
}
|
||||
|
||||
/* actually, the scl line is not observed, so this procedure does not return a value */
|
||||
static void i2c_read_scl_and_delay(void)
|
||||
{
|
||||
uint32_t dwMask = i2c_scl_pin_desc->ulPin;
|
||||
//PIO_Configure( i2c_scl_pin_desc->pPort, PIO_INPUT, i2c_scl_pin_desc->ulPin, PIO_DEFAULT ) ;
|
||||
//PIO_SetInput( i2c_scl_pin_desc->pPort, i2c_scl_pin_desc->ulPin, PIO_DEFAULT ) ;
|
||||
|
||||
/* set as input */
|
||||
i2c_scl_pin_desc->pPort->PIO_ODR = dwMask ;
|
||||
i2c_scl_pin_desc->pPort->PIO_PER = dwMask ;
|
||||
|
||||
i2c_delay();
|
||||
}
|
||||
|
||||
static void i2c_clear_scl(void)
|
||||
{
|
||||
uint32_t dwMask = i2c_scl_pin_desc->ulPin;
|
||||
|
||||
/* set open collector and drive low */
|
||||
//PIO_Configure( i2c_scl_pin_desc->pPort, PIO_OUTPUT_0, i2c_scl_pin_desc->ulPin, PIO_OPENDRAIN );
|
||||
//PIO_SetOutput( i2c_scl_pin_desc->pPort, i2c_scl_pin_desc->ulPin, 0, 1, 0);
|
||||
|
||||
/* open drain, zero default output */
|
||||
i2c_scl_pin_desc->pPort->PIO_MDER = dwMask;
|
||||
i2c_scl_pin_desc->pPort->PIO_CODR = dwMask;
|
||||
i2c_scl_pin_desc->pPort->PIO_OER = dwMask;
|
||||
i2c_scl_pin_desc->pPort->PIO_PER = dwMask;
|
||||
|
||||
//PIO_Clear( i2c_scl_pin_desc->pPort, i2c_scl_pin_desc->ulPin) ;
|
||||
}
|
||||
|
||||
static uint8_t i2c_read_sda(void)
|
||||
{
|
||||
uint32_t dwMask = i2c_sda_pin_desc->ulPin;
|
||||
//PIO_Configure( i2c_sda_pin_desc->pPort, PIO_INPUT, i2c_sda_pin_desc->ulPin, PIO_DEFAULT ) ;
|
||||
//PIO_SetInput( i2c_sda_pin_desc->pPort, i2c_sda_pin_desc->ulPin, PIO_DEFAULT ) ;
|
||||
|
||||
/* set as input */
|
||||
i2c_sda_pin_desc->pPort->PIO_ODR = dwMask ;
|
||||
i2c_sda_pin_desc->pPort->PIO_PER = dwMask ;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void i2c_clear_sda(void)
|
||||
{
|
||||
uint32_t dwMask = i2c_sda_pin_desc->ulPin;
|
||||
|
||||
/* set open collector and drive low */
|
||||
//PIO_Configure( i2c_sda_pin_desc->pPort, PIO_OUTPUT_0, i2c_sda_pin_desc->ulPin, PIO_OPENDRAIN );
|
||||
//PIO_SetOutput( i2c_sda_pin_desc->pPort, i2c_sda_pin_desc->ulPin, 0, 1, 0);
|
||||
|
||||
/* open drain, zero default output */
|
||||
i2c_sda_pin_desc->pPort->PIO_MDER = dwMask ;
|
||||
i2c_sda_pin_desc->pPort->PIO_CODR = dwMask ;
|
||||
i2c_sda_pin_desc->pPort->PIO_OER = dwMask ;
|
||||
i2c_sda_pin_desc->pPort->PIO_PER = dwMask ;
|
||||
|
||||
//PIO_Clear( i2c_sda_pin_desc->pPort, i2c_sda_pin_desc->ulPin) ;
|
||||
}
|
||||
|
||||
static void i2c_start(void)
|
||||
{
|
||||
if ( i2c_started != 0 )
|
||||
{
|
||||
/* if already started: do restart */
|
||||
i2c_read_sda(); /* SDA = 1 */
|
||||
i2c_delay();
|
||||
i2c_read_scl_and_delay();
|
||||
}
|
||||
i2c_read_sda();
|
||||
/*
|
||||
if (i2c_read_sda() == 0)
|
||||
{
|
||||
// do something because arbitration is lost
|
||||
}
|
||||
*/
|
||||
/* send the start condition, both lines go from 1 to 0 */
|
||||
i2c_clear_sda();
|
||||
i2c_delay();
|
||||
i2c_clear_scl();
|
||||
i2c_started = 1;
|
||||
}
|
||||
|
||||
|
||||
static void i2c_stop(void)
|
||||
{
|
||||
/* set SDA to 0 */
|
||||
i2c_clear_sda();
|
||||
i2c_delay();
|
||||
|
||||
/* now release all lines */
|
||||
i2c_read_scl_and_delay();
|
||||
|
||||
/* set SDA to 1 */
|
||||
i2c_read_sda();
|
||||
i2c_delay();
|
||||
i2c_started = 0;
|
||||
}
|
||||
|
||||
static void i2c_write_bit(uint8_t val)
|
||||
{
|
||||
if (val)
|
||||
i2c_read_sda();
|
||||
else
|
||||
i2c_clear_sda();
|
||||
|
||||
i2c_delay();
|
||||
i2c_read_scl_and_delay();
|
||||
i2c_clear_scl();
|
||||
}
|
||||
|
||||
static uint8_t i2c_read_bit(void)
|
||||
{
|
||||
uint8_t val;
|
||||
/* do not drive SDA */
|
||||
i2c_read_sda();
|
||||
i2c_delay();
|
||||
i2c_read_scl_and_delay();
|
||||
val = i2c_read_sda();
|
||||
i2c_delay();
|
||||
i2c_clear_scl();
|
||||
return val;
|
||||
}
|
||||
|
||||
static uint8_t i2c_write_byte(uint8_t b)
|
||||
{
|
||||
i2c_write_bit(b & 128);
|
||||
i2c_write_bit(b & 64);
|
||||
i2c_write_bit(b & 32);
|
||||
i2c_write_bit(b & 16);
|
||||
i2c_write_bit(b & 8);
|
||||
i2c_write_bit(b & 4);
|
||||
i2c_write_bit(b & 2);
|
||||
i2c_write_bit(b & 1);
|
||||
|
||||
/* read ack from client */
|
||||
/* 0: ack was given by client */
|
||||
/* 1: nothing happend during ack cycle */
|
||||
return i2c_read_bit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void u8g_i2c_init(uint8_t options)
|
||||
{
|
||||
u8g_i2c_opt = options;
|
||||
u8g_i2c_clear_error();
|
||||
|
||||
if ( u8g_i2c_opt & U8G_I2C_OPT_FAST )
|
||||
{
|
||||
i2c_delay = i2c_400KHz_delay;
|
||||
}
|
||||
else
|
||||
{
|
||||
i2c_delay = i2c_100KHz_delay;
|
||||
}
|
||||
|
||||
|
||||
if ( u8g_i2c_opt & U8G_I2C_OPT_DEV_1 )
|
||||
{
|
||||
i2c_scl_pin = PIN_WIRE1_SCL;
|
||||
i2c_sda_pin = PIN_WIRE1_SDA;
|
||||
|
||||
//REG_PIOA_PDR = PIO_PB12A_TWD1 | PIO_PB13A_TWCK1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
i2c_scl_pin = PIN_WIRE_SCL;
|
||||
i2c_sda_pin = PIN_WIRE_SDA;
|
||||
|
||||
//REG_PIOA_PDR = PIO_PA17A_TWD0 | PIO_PA18A_TWCK0;
|
||||
}
|
||||
|
||||
i2c_init();
|
||||
|
||||
}
|
||||
|
||||
/* sla includes also the r/w bit */
|
||||
uint8_t u8g_i2c_start(uint8_t sla)
|
||||
{
|
||||
i2c_start();
|
||||
i2c_write_byte(sla);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_send_byte(uint8_t data)
|
||||
{
|
||||
return i2c_write_byte(data);
|
||||
}
|
||||
|
||||
void u8g_i2c_stop(void)
|
||||
{
|
||||
i2c_stop();
|
||||
}
|
||||
|
||||
|
||||
#elif defined(U8G_RASPBERRY_PI)
|
||||
|
||||
#include <wiringPi.h>
|
||||
#include <wiringPiI2C.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define I2C_SLA 0x3c
|
||||
|
||||
static int fd=-1;
|
||||
static uint8_t i2cMode = 0;
|
||||
|
||||
void u8g_i2c_init(uint8_t options) {
|
||||
u8g_i2c_clear_error();
|
||||
u8g_i2c_opt = options;
|
||||
|
||||
if (wiringPiSetup() == -1) {
|
||||
printf("wiringPi-Error\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fd = wiringPiI2CSetup(I2C_SLA);
|
||||
if (fd < 0) {
|
||||
printf ("Unable to open I2C device 0: %s\n", strerror (errno)) ;
|
||||
exit (1) ;
|
||||
}
|
||||
//u8g_SetPIOutput(u8g, U8G_PI_RESET);
|
||||
//u8g_SetPIOutput(u8g, U8G_PI_A0);
|
||||
}
|
||||
uint8_t u8g_i2c_start(uint8_t sla) {
|
||||
u8g_i2c_send_mode(0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void u8g_i2c_stop(void) {
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_send_mode(uint8_t mode) {
|
||||
i2cMode = mode;
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_send_byte(uint8_t data) {
|
||||
wiringPiI2CWriteReg8(fd, i2cMode, data);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* empty interface */
|
||||
|
||||
void u8g_i2c_init(uint8_t options)
|
||||
{
|
||||
u8g_i2c_clear_error();
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_i2c_start(uint8_t sla)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
uint8_t u8g_i2c_send_byte(uint8_t data)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void u8g_i2c_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,452 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_com_io.c
|
||||
|
||||
abstraction layer for low level i/o
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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.
|
||||
|
||||
Update for ATOMIC operation done (01 Jun 2013)
|
||||
U8G_ATOMIC_OR(ptr, val)
|
||||
U8G_ATOMIC_AND(ptr, val)
|
||||
U8G_ATOMIC_START();
|
||||
U8G_ATOMIC_END();
|
||||
|
||||
uint8_t u8g_Pin(uint8_t port, uint8_t bitpos) Convert to internal number: AVR: port*8+bitpos, ARM: port*16+bitpos
|
||||
void u8g_SetPinOutput(uint8_t internal_pin_number)
|
||||
void u8g_SetPinInput(uint8_t internal_pin_number)
|
||||
void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level)
|
||||
uint8_t u8g_GetPinLevel(uint8_t internal_pin_number)
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#if defined(__AVR__)
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
typedef volatile uint8_t * IO_PTR;
|
||||
|
||||
/* create internal pin number */
|
||||
uint8_t u8g_Pin(uint8_t port, uint8_t bitpos)
|
||||
{
|
||||
port <<= 3;
|
||||
port += bitpos;
|
||||
return port;
|
||||
}
|
||||
|
||||
#if defined(__AVR_XMEGA__)
|
||||
|
||||
const IO_PTR u8g_avr_ddr_P[] PROGMEM = {
|
||||
#ifdef PORTA
|
||||
&PORTA.DIR,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
&PORTB.DIR,
|
||||
#ifdef PORTC
|
||||
&PORTC.DIR,
|
||||
#ifdef PORTD
|
||||
&PORTD.DIR,
|
||||
#ifdef PORTE
|
||||
&PORTE.DIR,
|
||||
#ifdef PORTF
|
||||
&PORTF.DIR,
|
||||
#ifdef PORTR
|
||||
&PORTR.DIR,
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
const IO_PTR u8g_avr_port_P[] PROGMEM = {
|
||||
#ifdef PORTA
|
||||
&PORTA.OUT,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
&PORTB.OUT,
|
||||
#ifdef PORTC
|
||||
&PORTC.OUT,
|
||||
#ifdef PORTD
|
||||
&PORTD.OUT,
|
||||
#ifdef PORTE
|
||||
&PORTE.OUT,
|
||||
#ifdef PORTF
|
||||
&PORTF.OUT,
|
||||
#ifdef PORTR
|
||||
&PORTR.OUT,
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
const IO_PTR u8g_avr_pin_P[] PROGMEM = {
|
||||
#ifdef PORTA
|
||||
&PORTA.IN,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
&PORTB.IN,
|
||||
#ifdef PORTC
|
||||
&PORTC.IN,
|
||||
#ifdef PORTD
|
||||
&PORTD.IN,
|
||||
#ifdef PORTE
|
||||
&PORTE.IN,
|
||||
#ifdef PORTF
|
||||
&PORTF.IN,
|
||||
#ifdef PORTR
|
||||
&PORTR.IN,
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#else
|
||||
const IO_PTR u8g_avr_ddr_P[] PROGMEM = {
|
||||
#ifdef DDRA
|
||||
&DDRA,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
&DDRB,
|
||||
#ifdef DDRC
|
||||
&DDRC,
|
||||
#ifdef DDRD
|
||||
&DDRD,
|
||||
#ifdef DDRE
|
||||
&DDRE,
|
||||
#ifdef DDRF
|
||||
&DDRF,
|
||||
#ifdef DDRG
|
||||
&DDRG,
|
||||
#ifdef DDRH
|
||||
&DDRH,
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
const IO_PTR u8g_avr_port_P[] PROGMEM = {
|
||||
#ifdef PORTA
|
||||
&PORTA,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
&PORTB,
|
||||
#ifdef PORTC
|
||||
&PORTC,
|
||||
#ifdef PORTD
|
||||
&PORTD,
|
||||
#ifdef PORTE
|
||||
&PORTE,
|
||||
#ifdef PORTF
|
||||
&PORTF,
|
||||
#ifdef PORTG
|
||||
&PORTG,
|
||||
#ifdef PORTH
|
||||
&PORTH,
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
const IO_PTR u8g_avr_pin_P[] PROGMEM = {
|
||||
#ifdef PINA
|
||||
&PINA,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
&PINB,
|
||||
#ifdef PINC
|
||||
&PINC,
|
||||
#ifdef PIND
|
||||
&PIND,
|
||||
#ifdef PINE
|
||||
&PINE,
|
||||
#ifdef PINF
|
||||
&PINF,
|
||||
#ifdef PING
|
||||
&PING,
|
||||
#ifdef PINH
|
||||
&PINH,
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
static volatile uint8_t *u8g_get_avr_io_ptr(const IO_PTR *base, uint8_t offset)
|
||||
{
|
||||
volatile uint8_t * tmp;
|
||||
base += offset;
|
||||
memcpy_P(&tmp, base, sizeof(volatile uint8_t * PROGMEM));
|
||||
return tmp;
|
||||
}
|
||||
|
||||
/* set direction to output of the specified pin (internal pin number) */
|
||||
void u8g_SetPinOutput(uint8_t internal_pin_number)
|
||||
{
|
||||
*u8g_get_avr_io_ptr(u8g_avr_ddr_P, internal_pin_number>>3) |= _BV(internal_pin_number&7);
|
||||
}
|
||||
|
||||
void u8g_SetPinInput(uint8_t internal_pin_number)
|
||||
{
|
||||
*u8g_get_avr_io_ptr(u8g_avr_ddr_P, internal_pin_number>>3) &= ~_BV(internal_pin_number&7);
|
||||
}
|
||||
|
||||
void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level)
|
||||
{
|
||||
volatile uint8_t * tmp = u8g_get_avr_io_ptr(u8g_avr_port_P, internal_pin_number>>3);
|
||||
|
||||
if ( level == 0 )
|
||||
{
|
||||
U8G_ATOMIC_AND(tmp, ~_BV(internal_pin_number&7));
|
||||
// *tmp &= ~_BV(internal_pin_number&7);
|
||||
}
|
||||
else
|
||||
{
|
||||
U8G_ATOMIC_OR(tmp, _BV(internal_pin_number&7));
|
||||
//*tmp |= _BV(internal_pin_number&7);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8g_GetPinLevel(uint8_t internal_pin_number)
|
||||
{
|
||||
volatile uint8_t * tmp = u8g_get_avr_io_ptr(u8g_avr_pin_P, internal_pin_number>>3);
|
||||
if ( ((*tmp) & _BV(internal_pin_number&7)) != 0 )
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined (__MSP430__)
|
||||
#include <msp430.h>
|
||||
|
||||
typedef volatile uint8_t * IO_PTR;
|
||||
|
||||
// MSP430 F5XXX / F6XXX series.
|
||||
const IO_PTR u8g_msp_ddr_P[] PROGMEM = {
|
||||
&P1DIR
|
||||
,&P2DIR
|
||||
,&P3DIR
|
||||
,&P4DIR
|
||||
,&P5DIR
|
||||
,&P6DIR
|
||||
,&P7DIR
|
||||
,&P8DIR
|
||||
#if defined (__MSP430_HAS_PORT9_R__)
|
||||
,&P9DIR
|
||||
#if defined (__MSP430_HAS_PORT10_R__)
|
||||
,&P10DIR
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
const IO_PTR u8g_msp_port_P[] PROGMEM = {
|
||||
&P1OUT
|
||||
,&P2OUT
|
||||
,&P3OUT
|
||||
,&P4OUT
|
||||
,&P5OUT
|
||||
,&P6OUT
|
||||
,&P7OUT
|
||||
,&P8OUT
|
||||
#if defined (__MSP430_HAS_PORT9_R__)
|
||||
,&P9OUT
|
||||
#if defined (__MSP430_HAS_PORT10_R__)
|
||||
,&P10OUT
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
const IO_PTR u8g_msp_pin_P[] PROGMEM = {
|
||||
&P1IN
|
||||
,&P2IN
|
||||
,&P3IN
|
||||
,&P4IN
|
||||
,&P5IN
|
||||
,&P6IN
|
||||
,&P7IN
|
||||
,&P8IN
|
||||
#if defined (__MSP430_HAS_PORT9_R__)
|
||||
,&P9IN
|
||||
#if defined (__MSP430_HAS_PORT10_R__)
|
||||
,&P10IN
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
uint8_t u8g_Pin(uint8_t port, uint8_t bitpos)
|
||||
{
|
||||
port <<= 3;
|
||||
port += bitpos;
|
||||
return port;
|
||||
}
|
||||
|
||||
void u8g_SetPinOutput(uint8_t internal_pin_number)
|
||||
{
|
||||
uint8_t port = (internal_pin_number >> 3)-1;
|
||||
uint8_t output = 1 << (internal_pin_number & 0x07);
|
||||
*u8g_msp_ddr_P[port] |= output;
|
||||
}
|
||||
|
||||
void u8g_SetPinInput(uint8_t internal_pin_number)
|
||||
{
|
||||
uint8_t port = (internal_pin_number >> 3)-1;
|
||||
*u8g_msp_ddr_P[port] &= ~(1 << (internal_pin_number & 0x07));
|
||||
}
|
||||
|
||||
void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level)
|
||||
{
|
||||
uint8_t port = (internal_pin_number >> 3)-1;
|
||||
if (level == 0)
|
||||
{
|
||||
*u8g_msp_port_P[port] &= ~(1 << (internal_pin_number & 0x07));
|
||||
}
|
||||
else
|
||||
{
|
||||
*u8g_msp_port_P[port]|= (1 << (internal_pin_number & 0x07));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t u8g_GetPinLevel(uint8_t internal_pin_number)
|
||||
{
|
||||
uint8_t port = (internal_pin_number >> 3)-1;
|
||||
uint8_t tmp = *u8g_msp_pin_P[port];
|
||||
if (tmp & (1 << (internal_pin_number & 0x07)))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#elif defined(U8G_RASPBERRY_PI)
|
||||
|
||||
#include <wiringPi.h>
|
||||
//#include "/usr/local/include/wiringPi.h"
|
||||
|
||||
void u8g_SetPinOutput(uint8_t internal_pin_number) {
|
||||
pinMode(internal_pin_number, OUTPUT);
|
||||
}
|
||||
|
||||
void u8g_SetPinInput(uint8_t internal_pin_number) {
|
||||
pinMode(internal_pin_number, INPUT);
|
||||
}
|
||||
|
||||
void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level) {
|
||||
digitalWrite(internal_pin_number, level);
|
||||
}
|
||||
|
||||
uint8_t u8g_GetPinLevel(uint8_t internal_pin_number) {
|
||||
return digitalRead(internal_pin_number);
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
/* convert "port" and "bitpos" to internal pin number */
|
||||
uint8_t u8g_Pin(uint8_t port, uint8_t bitpos)
|
||||
{
|
||||
port <<= 3;
|
||||
port += bitpos;
|
||||
return port;
|
||||
}
|
||||
|
||||
void u8g_SetPinOutput(uint8_t internal_pin_number)
|
||||
{
|
||||
}
|
||||
|
||||
void u8g_SetPinInput(uint8_t internal_pin_number)
|
||||
{
|
||||
}
|
||||
|
||||
void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level)
|
||||
{
|
||||
}
|
||||
|
||||
uint8_t u8g_GetPinLevel(uint8_t internal_pin_number)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(U8G_WITH_PINLIST)
|
||||
|
||||
void u8g_SetPIOutput(u8g_t *u8g, uint8_t pi)
|
||||
{
|
||||
uint8_t pin;
|
||||
pin = u8g->pin_list[pi];
|
||||
if ( pin != U8G_PIN_NONE )
|
||||
u8g_SetPinOutput(pin);
|
||||
}
|
||||
|
||||
void u8g_SetPILevel(u8g_t *u8g, uint8_t pi, uint8_t level)
|
||||
{
|
||||
uint8_t pin;
|
||||
pin = u8g->pin_list[pi];
|
||||
if ( pin != U8G_PIN_NONE )
|
||||
u8g_SetPinLevel(pin, level);
|
||||
}
|
||||
|
||||
#else /* defined(U8G_WITH_PINLIST) */
|
||||
void u8g_SetPIOutput(u8g_t *u8g, uint8_t pi)
|
||||
{
|
||||
}
|
||||
|
||||
void u8g_SetPILevel(u8g_t *u8g, uint8_t pi, uint8_t level)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* defined(U8G_WITH_PINLIST) */
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_com_null.c
|
||||
|
||||
communication null device
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
uint8_t u8g_com_null_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_COM_MSG_INIT:
|
||||
break;
|
||||
case U8G_COM_MSG_STOP:
|
||||
break;
|
||||
|
||||
|
||||
case U8G_COM_MSG_CHIP_SELECT:
|
||||
/* arg_val contains the chip number, which should be enabled */
|
||||
break;
|
||||
|
||||
|
||||
case U8G_COM_MSG_WRITE_BYTE:
|
||||
break;
|
||||
case U8G_COM_MSG_WRITE_SEQ:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_cursor.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
void u8g_SetCursorFont(u8g_t *u8g, const u8g_pgm_uint8_t *cursor_font)
|
||||
{
|
||||
u8g->cursor_font = cursor_font;
|
||||
}
|
||||
|
||||
void u8g_SetCursorStyle(u8g_t *u8g, uint8_t encoding)
|
||||
{
|
||||
u8g->cursor_encoding = encoding;
|
||||
}
|
||||
|
||||
void u8g_SetCursorColor(u8g_t *u8g, uint8_t fg, uint8_t bg)
|
||||
{
|
||||
u8g->cursor_bg_color = bg;
|
||||
u8g->cursor_fg_color = fg;
|
||||
}
|
||||
|
||||
void u8g_SetCursorPos(u8g_t *u8g, u8g_uint_t cursor_x, u8g_uint_t cursor_y)
|
||||
{
|
||||
u8g->cursor_x = cursor_x;
|
||||
u8g->cursor_y = cursor_y;
|
||||
}
|
||||
|
||||
void u8g_EnableCursor(u8g_t *u8g)
|
||||
{
|
||||
u8g->cursor_fn = u8g_DrawCursor;
|
||||
}
|
||||
|
||||
void u8g_DisableCursor(u8g_t *u8g)
|
||||
{
|
||||
u8g->cursor_fn = (u8g_draw_cursor_fn)0;
|
||||
}
|
||||
|
||||
void u8g_DrawCursor(u8g_t *u8g)
|
||||
{
|
||||
const u8g_pgm_uint8_t *font;
|
||||
uint8_t color;
|
||||
uint8_t encoding = u8g->cursor_encoding;
|
||||
|
||||
/* get current values */
|
||||
color = u8g_GetColorIndex(u8g);
|
||||
font = u8g->font;
|
||||
|
||||
/* draw cursor */
|
||||
u8g->font = u8g->cursor_font;
|
||||
encoding++;
|
||||
u8g_SetColorIndex(u8g, u8g->cursor_bg_color);
|
||||
/* 27. Jan 2013: replaced call to u8g_DrawGlyph with call to u8g_draw_glyph */
|
||||
/* required, because y adjustment should not happen to the cursor fonts */
|
||||
u8g_draw_glyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding);
|
||||
encoding--;
|
||||
u8g_SetColorIndex(u8g, u8g->cursor_fg_color);
|
||||
/* 27. Jan 2013: replaced call to u8g_DrawGlyph with call to u8g_draw_glyph */
|
||||
/* required, because y adjustment should not happen to the cursor fonts */
|
||||
/* u8g_DrawGlyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding); */
|
||||
u8g_draw_glyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding);
|
||||
|
||||
/* restore previous values */
|
||||
u8g->font = font;
|
||||
u8g_SetColorIndex(u8g, color);
|
||||
}
|
||||
|
@ -1,323 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_delay.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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.
|
||||
|
||||
|
||||
void u8g_Delay(uint16_t val) Delay by "val" milliseconds
|
||||
void u8g_MicroDelay(void) Delay be one microsecond
|
||||
void u8g_10MicroDelay(void) Delay by 10 microseconds
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/*==== Part 1: Derive suitable delay procedure ====*/
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
# if ARDUINO < 100
|
||||
# include <WProgram.h>
|
||||
# else
|
||||
# include <Arduino.h>
|
||||
# endif
|
||||
|
||||
/* issue 353 */
|
||||
#if defined(ARDUINO_ARCH_SAMD)
|
||||
# include <delay.h>
|
||||
#endif
|
||||
|
||||
# if defined(__AVR__)
|
||||
# define USE_AVR_DELAY
|
||||
# elif defined(__PIC32MX)
|
||||
# define USE_PIC32_DELAY
|
||||
# elif defined(__arm__) /* Arduino Due & Teensy */
|
||||
# define USE_ARDUINO_DELAY
|
||||
# else
|
||||
# define USE_ARDUINO_DELAY
|
||||
# endif
|
||||
#elif defined(_GNU_SOURCE)
|
||||
# define USE_LINUX_DELAY
|
||||
#elif defined(__MSP430__)
|
||||
# define USE_MSP430_DELAY
|
||||
#elif defined(U8G_RASPBERRY_PI)
|
||||
# define USE_RASPBERRYPI_DELAY
|
||||
#elif defined(__AVR__)
|
||||
# define USE_AVR_DELAY
|
||||
#elif defined(__18CXX)
|
||||
# define USE_PIC18_DELAY
|
||||
#elif defined(U8G_CYPRESS_PSOC5)
|
||||
#define USE_PSOC5_DELAY
|
||||
#elif defined(__arm__) || defined(__XTENSA__)
|
||||
/* do not define anything, all procedures are expected to be defined outside u8glib */
|
||||
|
||||
/*
|
||||
void u8g_Delay(uint16_t val);
|
||||
void u8g_MicroDelay(void);
|
||||
void u8g_10MicroDelay(void);
|
||||
*/
|
||||
|
||||
#else
|
||||
# define USE_DUMMY_DELAY
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*==== Part 2: Definition of the delay procedures ====*/
|
||||
|
||||
/*== Raspberry Pi Delay ==*/
|
||||
#if defined (USE_RASPBERRYPI_DELAY)
|
||||
#include <wiringPi.h>
|
||||
//#include "/usr/local/include/wiringPi.h"
|
||||
void u8g_Delay(uint16_t val) {
|
||||
//delay(val);
|
||||
//usleep((uint32_t)val*(uint32_t)1000);
|
||||
delayMicroseconds((uint32_t)val*(uint32_t)1000);
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
usleep(1);
|
||||
}
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
usleep(10);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_LINUX_DELAY)
|
||||
void u8g_Delay(uint16_t val) {
|
||||
//delay(val);
|
||||
usleep((uint32_t)val*(uint32_t)1000);
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
usleep(1);
|
||||
}
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
usleep(10);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*== AVR Delay ==*/
|
||||
|
||||
#if defined(USE_AVR_DELAY)
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
/*
|
||||
Delay by the provided number of milliseconds.
|
||||
Thus, a 16 bit value will allow a delay of 0..65 seconds
|
||||
Makes use of the _delay_loop_2
|
||||
|
||||
_delay_loop_2 will do a delay of n * 4 prozessor cycles.
|
||||
with f = F_CPU cycles per second,
|
||||
n = f / (1000 * 4 )
|
||||
with f = 16000000 the result is 4000
|
||||
with f = 1000000 the result is 250
|
||||
|
||||
the millisec loop, gcc requires the following overhead:
|
||||
- movev 1
|
||||
- subwi 2x2
|
||||
- bne i 2
|
||||
==> 7 cycles
|
||||
==> must be devided by 4, rounded up 7/4 = 2
|
||||
*/
|
||||
void u8g_Delay(uint16_t val)
|
||||
{
|
||||
/* old version did a call to the arduino lib: delay(val); */
|
||||
while( val != 0 )
|
||||
{
|
||||
_delay_loop_2( (F_CPU / 4000 ) -2);
|
||||
val--;
|
||||
}
|
||||
}
|
||||
|
||||
/* delay by one micro second */
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
#if (F_CPU / 4000000 ) > 0
|
||||
_delay_loop_2( (F_CPU / 4000000 ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
/* delay by 10 micro seconds */
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
#if (F_CPU / 400000 ) > 0
|
||||
_delay_loop_2( (F_CPU / 400000 ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*== Delay for PIC18 (not tested) ==*/
|
||||
|
||||
#if defined(USE_PIC18_DELAY)
|
||||
#include <delays.h>
|
||||
#define GetSystemClock() (64000000ul) // Hz
|
||||
#define GetInstructionClock() (GetSystemClock()/4)
|
||||
|
||||
void u8g_Delay(uint16_t val)
|
||||
{/*
|
||||
unsigned int _iTemp = (val);
|
||||
while(_iTemp--)
|
||||
Delay1KTCYx((GetInstructionClock()+999999)/1000000);
|
||||
*/
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
/* not implemented */
|
||||
}
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
/* not implemented */
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*== Arduino Delay ==*/
|
||||
#if defined(USE_ARDUINO_DELAY)
|
||||
void u8g_Delay(uint16_t val)
|
||||
{
|
||||
#if defined(__arm__)
|
||||
delayMicroseconds((uint32_t)val*(uint32_t)1000);
|
||||
#else
|
||||
delay(val);
|
||||
#endif
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
delayMicroseconds(1);
|
||||
}
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
delayMicroseconds(10);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(USE_PIC32_DELAY)
|
||||
/*
|
||||
Assume chipkit here with F_CPU correctly defined
|
||||
The problem was, that u8g_Delay() is called within the constructor.
|
||||
It seems that the chipkit is not fully setup at this time, so a
|
||||
call to delay() will not work. So here is my own implementation.
|
||||
|
||||
*/
|
||||
#define CPU_COUNTS_PER_SECOND (F_CPU/2UL)
|
||||
#define TICKS_PER_MILLISECOND (CPU_COUNTS_PER_SECOND/1000UL)
|
||||
#include "plib.h"
|
||||
void u8g_Delay(uint16_t val)
|
||||
{
|
||||
uint32_t d;
|
||||
uint32_t s;
|
||||
d = val;
|
||||
d *= TICKS_PER_MILLISECOND;
|
||||
s = ReadCoreTimer();
|
||||
while ( (uint32_t)(ReadCoreTimer() - s) < d )
|
||||
;
|
||||
}
|
||||
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
uint32_t d;
|
||||
uint32_t s;
|
||||
d = TICKS_PER_MILLISECOND/1000;
|
||||
s = ReadCoreTimer();
|
||||
while ( (uint32_t)(ReadCoreTimer() - s) < d )
|
||||
;
|
||||
}
|
||||
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
uint32_t d;
|
||||
uint32_t s;
|
||||
d = TICKS_PER_MILLISECOND/100;
|
||||
s = ReadCoreTimer();
|
||||
while ( (uint32_t)(ReadCoreTimer() - s) < d )
|
||||
;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(USE_MSP430_DELAY)
|
||||
#include <msp430.h>
|
||||
|
||||
#ifndef F_CPU
|
||||
#define F_CPU 1000000UL
|
||||
#endif
|
||||
|
||||
|
||||
void u8g_Delay(uint16_t val)
|
||||
{
|
||||
int t;
|
||||
for (t=0; t < val; t++)
|
||||
{
|
||||
__delay_cycles(F_CPU/1000UL);
|
||||
}
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
__delay_cycles(F_CPU/1000000UL);
|
||||
}
|
||||
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
__delay_cycles(F_CPU/100000UL);
|
||||
}
|
||||
#endif
|
||||
#if defined USE_PSOC5_DELAY
|
||||
#include <project.h>
|
||||
void u8g_Delay(uint16_t val) {CyDelay(val);};
|
||||
void u8g_MicroDelay(void) {CyDelay(1);};
|
||||
void u8g_10MicroDelay(void) {CyDelay(10);};
|
||||
#endif
|
||||
|
||||
|
||||
/*== Any other systems: Dummy Delay ==*/
|
||||
#if defined(USE_DUMMY_DELAY)
|
||||
void u8g_Delay(uint16_t val)
|
||||
{
|
||||
/* do not know how to delay... */
|
||||
}
|
||||
void u8g_MicroDelay(void)
|
||||
{
|
||||
}
|
||||
void u8g_10MicroDelay(void)
|
||||
{
|
||||
}
|
||||
#endif
|
@ -1,199 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_a2_micro_printer_ds.c
|
||||
|
||||
Use DC2 bitmap command of the A2 Micro panel termal printer
|
||||
double stroke
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, 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 "u8g.h"
|
||||
|
||||
#define LINE_DELAY 40
|
||||
|
||||
|
||||
uint8_t u8g_dev_a2_micro_printer_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i, j;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
|
||||
u8g_WriteByte(u8g, dev, 27); /* ESC */
|
||||
u8g_WriteByte(u8g, dev, 55 ); /* parameter command */
|
||||
u8g_WriteByte(u8g, dev, 7); /* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1)*/
|
||||
u8g_WriteByte(u8g, dev, 160); /* 3-255 Heating time,Unit(10us),Default:80(800us) */
|
||||
u8g_WriteByte(u8g, dev, 20); /* 0-255 Heating interval,Unit(10us),Default:2(20us)*/
|
||||
|
||||
u8g_WriteByte(u8g, dev, 18); /* DC2 */
|
||||
u8g_WriteByte(u8g, dev, 42 ); /* * */
|
||||
u8g_WriteByte(u8g, dev, pb->p.page_height );
|
||||
u8g_WriteByte(u8g, dev, pb->width/8 );
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i ++ )
|
||||
{
|
||||
for( j = 0; j < pb->width/8; j++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, *ptr);
|
||||
ptr++;
|
||||
}
|
||||
u8g_Delay(u8g, LINE_DELAY);
|
||||
y++;
|
||||
}
|
||||
|
||||
/* set parameters back to their default values */
|
||||
u8g_WriteByte(u8g, dev, 27); /* ESC */
|
||||
u8g_WriteByte(u8g, dev, 55 ); /* parameter command */
|
||||
u8g_WriteByte(u8g, dev, 7); /* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1)*/
|
||||
u8g_WriteByte(u8g, dev, 80); /* 3-255 Heating time,Unit(10us),Default:80(800us) */
|
||||
u8g_WriteByte(u8g, dev, 2); /* 0-255 Heating interval,Unit(10us),Default:2(20us)*/
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
static uint8_t u8g_dev_expand4(uint8_t val)
|
||||
{
|
||||
uint8_t a,b,c,d;
|
||||
a = val&1;
|
||||
b = (val&2)<<1;
|
||||
c = (val&4)<<2;
|
||||
d = (val&8)<<3;
|
||||
a |=b;
|
||||
a |=c;
|
||||
a |=d;
|
||||
a |= a<<1;
|
||||
return a;
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_a2_micro_printer_double_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
{
|
||||
//u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
//u8g_WriteByte(u8g, dev, 18); /* DC2 */
|
||||
//u8g_WriteByte(u8g, dev, 42 ); /* * */
|
||||
//u8g_WriteByte(u8g, dev, pb->p.total_height*2 );
|
||||
//u8g_WriteByte(u8g, dev, pb->width/8*2 );
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i, j;
|
||||
uint8_t *ptr;
|
||||
uint8_t *p2;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
//u8g_WriteByte(u8g, dev, 18); /* DC2 */
|
||||
//u8g_WriteByte(u8g, dev, 35 ); /* # */
|
||||
//u8g_WriteByte(u8g, dev, 0x0ff ); /* max */
|
||||
|
||||
u8g_WriteByte(u8g, dev, 27); /* ESC */
|
||||
u8g_WriteByte(u8g, dev, 55 ); /* parameter command */
|
||||
u8g_WriteByte(u8g, dev, 7); /* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1)*/
|
||||
u8g_WriteByte(u8g, dev, 160); /* 3-255 Heating time,Unit(10us),Default:80(800us) */
|
||||
u8g_WriteByte(u8g, dev, 20); /* 0-255 Heating interval,Unit(10us),Default:2(20us)*/
|
||||
|
||||
u8g_WriteByte(u8g, dev, 18); /* DC2 */
|
||||
u8g_WriteByte(u8g, dev, 42 ); /* * */
|
||||
u8g_WriteByte(u8g, dev, pb->p.page_height*2 );
|
||||
u8g_WriteByte(u8g, dev, pb->width/8*2 );
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i ++ )
|
||||
{
|
||||
p2 = ptr;
|
||||
for( j = 0; j < pb->width/8; j++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_expand4(*p2 >> 4));
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_expand4(*p2 & 15));
|
||||
p2++;
|
||||
}
|
||||
u8g_Delay(u8g, LINE_DELAY);
|
||||
p2 = ptr;
|
||||
for( j = 0; j < pb->width/8; j++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_expand4(*p2 >> 4));
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_expand4(*p2 & 15));
|
||||
p2++;
|
||||
}
|
||||
u8g_Delay(u8g, LINE_DELAY);
|
||||
ptr += pb->width/8;
|
||||
y++;
|
||||
}
|
||||
|
||||
/* set parameters back to their default values */
|
||||
u8g_WriteByte(u8g, dev, 27); /* ESC */
|
||||
u8g_WriteByte(u8g, dev, 55 ); /* parameter command */
|
||||
u8g_WriteByte(u8g, dev, 7); /* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1)*/
|
||||
u8g_WriteByte(u8g, dev, 80); /* 3-255 Heating time,Unit(10us),Default:80(800us) */
|
||||
u8g_WriteByte(u8g, dev, 2); /* 0-255 Heating interval,Unit(10us),Default:2(20us)*/
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
#if defined(U8G_16BIT)
|
||||
U8G_PB_DEV(u8g_dev_a2_micro_printer_384x240, 384, 240, 8, u8g_dev_a2_micro_printer_fn, u8g_com_null_fn);
|
||||
U8G_PB_DEV(u8g_dev_a2_micro_printer_192x360_ds, 192, 360, 8, u8g_dev_a2_micro_printer_double_fn, u8g_com_null_fn);
|
||||
U8G_PB_DEV(u8g_dev_a2_micro_printer_192x720_ds, 192, 720, 8, u8g_dev_a2_micro_printer_double_fn, u8g_com_null_fn);
|
||||
#else
|
||||
U8G_PB_DEV(u8g_dev_a2_micro_printer_384x240, 240, 240, 8, u8g_dev_a2_micro_printer_fn, u8g_com_null_fn);
|
||||
U8G_PB_DEV(u8g_dev_a2_micro_printer_192x360_ds, 192, 240, 8, u8g_dev_a2_micro_printer_double_fn, u8g_com_null_fn);
|
||||
U8G_PB_DEV(u8g_dev_a2_micro_printer_192x720_ds, 192, 240, 8, u8g_dev_a2_micro_printer_double_fn, u8g_com_null_fn);
|
||||
#endif
|
||||
|
||||
U8G_PB_DEV(u8g_dev_a2_micro_printer_192x120_ds, 192, 120, 8, u8g_dev_a2_micro_printer_double_fn, u8g_com_null_fn);
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_flipdisc.c
|
||||
|
||||
1-Bit (BW) Driver for flip disc matrix
|
||||
2x 7 pixel height
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 28
|
||||
#define HEIGHT 14
|
||||
#define PAGE_HEIGHT 14
|
||||
|
||||
/*
|
||||
Write data to the flip disc matrix.
|
||||
This procedure must be implemented by the user.
|
||||
Arguments:
|
||||
id: Id for the matrix. Currently always 0.
|
||||
page: A page has a height of 14 pixel. For a matrix with HEIGHT == 14 this will be always 0
|
||||
width: The width of the flip disc matrix. Always equal to WIDTH
|
||||
row1: first data line (7 pixel per byte)
|
||||
row2: first data line (7 pixel per byte)
|
||||
*/
|
||||
void writeFlipDiscMatrix(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2);
|
||||
|
||||
|
||||
|
||||
void (*u8g_write_flip_disc_matrix)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2);
|
||||
|
||||
void u8g_SetFlipDiscCallback(u8g_t *u8g, void (*cb)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2))
|
||||
{
|
||||
u8g_write_flip_disc_matrix = cb;
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_flipdisc_2x7_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
/* current page: pb->p.page */
|
||||
/* ptr to the buffer: pb->buf */
|
||||
|
||||
(*u8g_write_flip_disc_matrix)(0, pb->p.page, WIDTH, pb->buf, (uint8_t *)(pb->buf)+WIDTH);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb14v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_flipdisc_2x7_bw_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_flipdisc_2x7_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_flipdisc_2x7_bw_buf};
|
||||
u8g_dev_t u8g_dev_flipdisc_2x7 = { u8g_dev_flipdisc_2x7_bw_fn, &u8g_dev_flipdisc_2x7_bw_pb, u8g_com_null_fn };
|
@ -1,130 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_gprof.c
|
||||
|
||||
Device for performance measurement with gprof.
|
||||
Does not write any data, but uses a buffer.
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
uint8_t u8g_dev_gprof_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
uint8_t u8g_pb_dev_gprof_buf[WIDTH];
|
||||
u8g_pb_t u8g_pb_dev_gprof = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_pb_dev_gprof_buf };
|
||||
|
||||
u8g_dev_t u8g_dev_gprof = { u8g_dev_gprof_fn, &u8g_pb_dev_gprof, NULL };
|
||||
|
||||
uint8_t u8g_dev_gprof_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
/*
|
||||
{
|
||||
uint8_t i, j;
|
||||
uint8_t page_height;
|
||||
page_height = pb->p.page_y1;
|
||||
page_height -= pb->p.page_y0;
|
||||
page_height++;
|
||||
for( j = 0; j < page_height; j++ )
|
||||
{
|
||||
printf("%02d ", j);
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
if ( (u8g_pb_dev_stdout_buf[i] & (1<<j)) != 0 )
|
||||
printf("#");
|
||||
else
|
||||
printf(".");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
*/
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
{
|
||||
//printf("\n");
|
||||
return 0;
|
||||
}
|
||||
u8g_pb_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
{
|
||||
u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
|
||||
u8g_uint_t x2, y2;
|
||||
|
||||
y2 = bbx->y;
|
||||
y2 += bbx->h;
|
||||
y2--;
|
||||
|
||||
if ( u8g_pb_IsYIntersection(pb, bbx->y, y2) == 0 )
|
||||
return 0;
|
||||
|
||||
/* maybe this one can be skiped... probability is very high to have an intersection, so it would be ok to always return 1 */
|
||||
x2 = bbx->x;
|
||||
x2 += bbx->w;
|
||||
x2--;
|
||||
|
||||
if ( u8g_pb_IsXIntersection(pb, bbx->x, x2) == 0 )
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
@ -1,281 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ht1632.c
|
||||
|
||||
1-Bit (BW) Driver for HT1632 controller
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, 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.
|
||||
|
||||
|
||||
|
||||
U8G_PIN_NONE can be used as argument
|
||||
|
||||
uint8_t u8g_InitSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset)
|
||||
{
|
||||
...
|
||||
u8g->pin_list[U8G_PI_SCK] = sck;
|
||||
u8g->pin_list[U8G_PI_MOSI] = mosi;
|
||||
u8g->pin_list[U8G_PI_CS] = cs;
|
||||
u8g->pin_list[U8G_PI_A0] = a0;
|
||||
u8g->pin_list[U8G_PI_RESET] = reset;
|
||||
|
||||
mapping
|
||||
|
||||
#define DATA_PIN --> U8G_PI_MOSI
|
||||
#define WR_PIN --> U8G_PI_SCK
|
||||
#define CS_PIN --> U8G_PI_CS
|
||||
U8G_PI_A0 --> not used
|
||||
U8G_PI_RESET --> not used
|
||||
|
||||
Usage:
|
||||
|
||||
u8g_InitSPI(&u8g, &u8g_dev_ht1632_24x16, WR_PIN, DATA_IN, CS_PIN, U8G_PIN_NONE, U8G_PIN_NONE)
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 24
|
||||
#define HEIGHT 16
|
||||
#define PAGE_HEIGHT 16
|
||||
|
||||
/* http://forum.arduino.cc/index.php?topic=168537.0 */
|
||||
|
||||
#define HT1632_CMD_SYSDIS 0x00 // CMD= 0000-0000-x Turn off oscil
|
||||
#define HT1632_CMD_SYSON 0x01 // CMD= 0000-0001-x Enable system oscil
|
||||
#define HT1632_CMD_LEDOFF 0x02 // CMD= 0000-0010-x LED duty cycle gen off
|
||||
#define HT1632_CMD_LEDON 0x03 // CMD= 0000-0011-x LEDs ON
|
||||
#define HT1632_CMD_BLOFF 0x08 // CMD= 0000-1000-x Blink OFF
|
||||
#define HT1632_CMD_BLON 0x09 // CMD= 0000-1001-x Blink On
|
||||
#define HT1632_CMD_SLVMD 0x10 // CMD= 0001-00xx-x Slave Mode
|
||||
#define HT1632_CMD_MSTMD 0x14 // CMD= 0001-01xx-x Master Mode
|
||||
#define HT1632_CMD_RCCLK 0x18 // CMD= 0001-10xx-x Use on-chip clock
|
||||
#define HT1632_CMD_EXTCLK 0x1C // CMD= 0001-11xx-x Use external clock
|
||||
#define HT1632_CMD_COMS00 0x20 // CMD= 0010-ABxx-x commons options
|
||||
#define HT1632_CMD_COMS01 0x24 // CMD= 0010-ABxx-x commons options
|
||||
#define HT1632_CMD_COMS10 0x28 // CMD= 0010-ABxx-x commons options
|
||||
#define HT1632_CMD_COMS11 0x2C // P-MOS OUTPUT AND 16COMMON OPTION
|
||||
#define HT1632_CMD_PWM 0xA0 // CMD= 101x-PPPP-x PWM duty cycle
|
||||
|
||||
#define HT1632_ID_CMD 4 /* ID = 100 - Commands */
|
||||
#define HT1632_ID_RD 6 /* ID = 110 - Read RAM */
|
||||
#define HT1632_ID_WR 5 /* ID = 101 - Write RAM */
|
||||
|
||||
#define HT1632_ID_LEN 3 // IDs are 3 bits
|
||||
#define HT1632_CMD_LEN 8 // CMDs are 8 bits
|
||||
#define HT1632_DATA_LEN 8 // Data are 4*2 bits
|
||||
#define HT1632_ADDR_LEN 7 // Address are 7 bits
|
||||
|
||||
#if defined(ARDUINO)
|
||||
|
||||
#if ARDUINO < 100
|
||||
#include <WProgram.h>
|
||||
#else
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
//#define WR_PIN 3
|
||||
//#define DATA_PIN 2
|
||||
//#define CS_PIN 4
|
||||
|
||||
void ht1632_write_data_MSB(u8g_t *u8g, uint8_t cnt, uint8_t data, uint8_t extra)
|
||||
{
|
||||
int8_t i;
|
||||
uint8_t data_pin = u8g->pin_list[U8G_PI_MOSI];
|
||||
uint8_t wr_pin = u8g->pin_list[U8G_PI_SCK];
|
||||
|
||||
for(i = cnt - 1; i >= 0; i--)
|
||||
{
|
||||
if ((data >> i) & 1)
|
||||
{
|
||||
digitalWrite(data_pin, HIGH);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(data_pin, LOW);
|
||||
}
|
||||
|
||||
digitalWrite(wr_pin, LOW);
|
||||
u8g_MicroDelay();
|
||||
digitalWrite(wr_pin, HIGH);
|
||||
u8g_MicroDelay();
|
||||
}
|
||||
|
||||
// Send an extra bit
|
||||
if (extra)
|
||||
{
|
||||
digitalWrite(data_pin, HIGH);
|
||||
digitalWrite(wr_pin, LOW);
|
||||
u8g_MicroDelay();
|
||||
digitalWrite(wr_pin, HIGH);
|
||||
u8g_MicroDelay();
|
||||
}
|
||||
}
|
||||
|
||||
void ht1632_write_data(u8g_t *u8g, uint8_t cnt, uint8_t data)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t data_pin = u8g->pin_list[U8G_PI_MOSI];
|
||||
uint8_t wr_pin = u8g->pin_list[U8G_PI_SCK];
|
||||
for (i = 0; i < cnt; i++)
|
||||
{
|
||||
|
||||
if ((data >> i) & 1) {
|
||||
digitalWrite(data_pin, HIGH);
|
||||
}
|
||||
else {
|
||||
digitalWrite(data_pin, LOW);
|
||||
}
|
||||
|
||||
digitalWrite(wr_pin, LOW);
|
||||
u8g_MicroDelay();
|
||||
digitalWrite(wr_pin, HIGH);
|
||||
u8g_MicroDelay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ht1632_init(u8g_t *u8g)
|
||||
{
|
||||
//uint8_t i;
|
||||
uint8_t data_pin = u8g->pin_list[U8G_PI_MOSI];
|
||||
uint8_t wr_pin = u8g->pin_list[U8G_PI_SCK];
|
||||
uint8_t cs_pin = u8g->pin_list[U8G_PI_CS];
|
||||
pinMode(data_pin, OUTPUT);
|
||||
pinMode(wr_pin, OUTPUT);
|
||||
pinMode(cs_pin, OUTPUT);
|
||||
|
||||
digitalWrite(data_pin, HIGH);
|
||||
digitalWrite(wr_pin, HIGH);
|
||||
digitalWrite(cs_pin, HIGH);
|
||||
|
||||
digitalWrite(cs_pin, LOW);
|
||||
/* init display once after startup */
|
||||
ht1632_write_data_MSB(u8g, 3, HT1632_ID_CMD, false); // IDs are 3 bits
|
||||
ht1632_write_data_MSB(u8g, 8, HT1632_CMD_SYSDIS, true); // 8 bits
|
||||
ht1632_write_data_MSB(u8g, 8, HT1632_CMD_SYSON, true); // 8 bits
|
||||
ht1632_write_data_MSB(u8g, 8, HT1632_CMD_COMS11, true); // 8 bits
|
||||
ht1632_write_data_MSB(u8g, 8, HT1632_CMD_LEDON, true); // 8 bits
|
||||
ht1632_write_data_MSB(u8g, 8, HT1632_CMD_BLOFF, true); // 8 bits
|
||||
ht1632_write_data_MSB(u8g, 8, HT1632_CMD_PWM+15, true); // 8 bits
|
||||
digitalWrite(cs_pin, HIGH);
|
||||
|
||||
/* removed following (debug) code */
|
||||
/*
|
||||
digitalWrite(cs_pin, LOW);
|
||||
ht1632_write_data_MSB(u8g, 3, HT1632_ID_WR, false); // Send "write to display" command
|
||||
ht1632_write_data_MSB(u8g, 7, 0, false);
|
||||
for(i = 0; i<48; ++i)
|
||||
{
|
||||
ht1632_write_data(u8g, 8, 0xFF);
|
||||
}
|
||||
digitalWrite(cs_pin, HIGH);
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
page: 0=data contain lines 0..16, 1=data contain lines 16..32 (a 24x16 display will only have page 0)
|
||||
cnt: width of the display
|
||||
data: pointer to a buffer with 2*cnt bytes.
|
||||
*/
|
||||
void ht1632_transfer_data(u8g_t *u8g, uint8_t page, uint8_t cnt, uint8_t *data)
|
||||
{
|
||||
uint8_t addr;
|
||||
uint8_t cs_pin = u8g->pin_list[U8G_PI_CS];
|
||||
/* send data to the ht1632 */
|
||||
digitalWrite(cs_pin, LOW);
|
||||
ht1632_write_data_MSB(u8g, 3, HT1632_ID_WR, false); // Send "write to display" command
|
||||
ht1632_write_data_MSB(u8g, 7, page*2*cnt, false);
|
||||
|
||||
// Operating in progressive addressing mode
|
||||
for (addr = 0; addr < cnt; addr++)
|
||||
{
|
||||
ht1632_write_data(u8g, 8, data[addr]);
|
||||
ht1632_write_data(u8g, 8, data[addr+cnt]);
|
||||
}
|
||||
digitalWrite(cs_pin, HIGH);
|
||||
}
|
||||
|
||||
/* value is between 0...15 */
|
||||
void ht1632_set_contrast(u8g_t *u8g, uint8_t value)
|
||||
{
|
||||
uint8_t cs_pin = u8g->pin_list[U8G_PI_CS];
|
||||
digitalWrite(cs_pin, LOW);
|
||||
ht1632_write_data_MSB(u8g, 3, HT1632_ID_CMD, false);
|
||||
ht1632_write_data_MSB(u8g, 8, HT1632_CMD_PWM + value, false);
|
||||
digitalWrite(cs_pin, HIGH);
|
||||
}
|
||||
|
||||
#else
|
||||
void ht1632_init(u8g_t *u8g)
|
||||
{
|
||||
}
|
||||
|
||||
void ht1632_transfer_data(u8g_t *u8g, uint8_t page, uint8_t cnt, uint8_t *data)
|
||||
{
|
||||
}
|
||||
|
||||
void ht1632_set_contrast(u8g_t *u8g, uint8_t value)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* ARDUINO */
|
||||
|
||||
|
||||
uint8_t u8g_dev_ht1632_24x16_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
ht1632_init(u8g);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
/* current page: pb->p.page */
|
||||
/* ptr to the buffer: pb->buf */
|
||||
ht1632_transfer_data(u8g, pb->p.page, WIDTH, pb->buf);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
/* values passed to SetContrast() are between 0 and 255, scale down to 0...15 */
|
||||
ht1632_set_contrast(u8g, (*(uint8_t *)arg) >> 4);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ht1632_24x16_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ht1632_24x16_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ht1632_24x16_buf};
|
||||
u8g_dev_t u8g_dev_ht1632_24x16 = { u8g_dev_ht1632_24x16_fn, &u8g_dev_ht1632_24x16_pb, u8g_com_null_fn };
|
||||
|
@ -1,326 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ili9325d_320x240.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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.
|
||||
|
||||
Color format
|
||||
Red: 5 Bit
|
||||
Green: 6 Bit
|
||||
Blue: 5 Bit
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
|
||||
#if defined(U8G_16BIT)
|
||||
#define HEIGHT 320
|
||||
#else
|
||||
/* if the user tries to compile the 8Bit version of the lib, then restrict the height to something which fits to 8Bit */
|
||||
#define HEIGHT 240
|
||||
#endif
|
||||
#define PAGE_HEIGHT 4
|
||||
|
||||
|
||||
/*
|
||||
reference board for this device:
|
||||
http://iteadstudio.com/store/index.php?main_page=product_info&cPath=57_58&products_id=55
|
||||
documentation:
|
||||
http://iteadstudio.com/Downloadfile/ITDB02_material.rar
|
||||
datasheet
|
||||
http://www.newhavendisplay.com/app_notes/ILI9325D.pdf
|
||||
other libs
|
||||
http://henningkarlsen.com/electronics/library.php
|
||||
init sequence
|
||||
http://code.google.com/p/itdb02/, ITDB02.cpp, iteadstudio.com
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_ili9325d_320x240_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
|
||||
//U8G_ESC_ADR(0), 0x000, 0x0E5, /* only used for none D version: set SRAM internal timing */
|
||||
//U8G_ESC_ADR(1), 0x078, 0x0f0,
|
||||
U8G_ESC_ADR(0), 0x000, 0x001, /* Driver Output Control, bits 8 & 10 */
|
||||
U8G_ESC_ADR(1), 0x001, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x002, /* LCD Driving Wave Control, bit 9: Set line inversion */
|
||||
U8G_ESC_ADR(1), 0x002, 0x000, /* ITDB02 none D verion: 0x007, 0x000 */
|
||||
U8G_ESC_ADR(0), 0x000, 0x003, /* Entry Mode, GRAM write direction and BGR=1 */
|
||||
U8G_ESC_ADR(1), 0x010, 0x030,
|
||||
U8G_ESC_ADR(0), 0x000, 0x004, /* Resize register */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x008, /* Display Control 2: set the back porch and front porch */
|
||||
U8G_ESC_ADR(1), 0x002, 0x007,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x009, /* Display Control 3 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x00a, /* Display Control 4: FMARK */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x00c, /* RGB Display Interface Control 1 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x00d, /* Frame Maker Position */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x00f, /* RGB Display Interface Control 2 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x010, /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x011, /* Power Control 2: DC1[2:0], DC0[2:0], VC[2:0] */
|
||||
U8G_ESC_ADR(1), 0x000, 0x007,
|
||||
U8G_ESC_ADR(0), 0x000, 0x012, /* Power Control 3: VREG1OUT voltage */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x013, /* Power Control 4: VDV[4:0] for VCOM amplitude */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x007, /* Display Control 1: Operate, but do not display */
|
||||
U8G_ESC_ADR(1), 0x000, 0x001,
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */ /* ITDB02 none D verion: 50ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x010, /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
U8G_ESC_ADR(1), 0x016, 0x090, /* ITDB02 none D verion: 0x010, 0x090 */
|
||||
U8G_ESC_ADR(0), 0x000, 0x011, /* Power Control 2: SAP, BT[3:0], AP, DSTB, SLP, STB */
|
||||
U8G_ESC_ADR(1), 0x002, 0x027,
|
||||
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x012, /* Power Control 3: VCI: External, VCI*1.80 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x00d, /* ITDB02 none D verion: 0x000, 0x01f */
|
||||
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x013, /* Power Control 4: VDV[4:0] for VCOM amplitude */
|
||||
U8G_ESC_ADR(1), 0x012, 0x000, /* ITDB02 none D verion: 0x015, 0x000 */
|
||||
U8G_ESC_ADR(0), 0x000, 0x029, /* Power Control 7 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x00a, /* ITDB02 none D verion: 0x000, 0x027 */
|
||||
U8G_ESC_ADR(0), 0x000, 0x02b, /* Frame Rate: 83 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x00d,
|
||||
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x020, /* Horizontal GRAM Address Set */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x021, /* Vertical GRAM Address Set */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
|
||||
/* gamma control */
|
||||
U8G_ESC_ADR(0), 0x000, 0x030,
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x031,
|
||||
U8G_ESC_ADR(1), 0x004, 0x004,
|
||||
U8G_ESC_ADR(0), 0x000, 0x032,
|
||||
U8G_ESC_ADR(1), 0x000, 0x003,
|
||||
U8G_ESC_ADR(0), 0x000, 0x035,
|
||||
U8G_ESC_ADR(1), 0x004, 0x005,
|
||||
U8G_ESC_ADR(0), 0x000, 0x036,
|
||||
U8G_ESC_ADR(1), 0x008, 0x008,
|
||||
U8G_ESC_ADR(0), 0x000, 0x037,
|
||||
U8G_ESC_ADR(1), 0x004, 0x007,
|
||||
U8G_ESC_ADR(0), 0x000, 0x038,
|
||||
U8G_ESC_ADR(1), 0x003, 0x003,
|
||||
U8G_ESC_ADR(0), 0x000, 0x039,
|
||||
U8G_ESC_ADR(1), 0x007, 0x007,
|
||||
U8G_ESC_ADR(0), 0x000, 0x03c,
|
||||
U8G_ESC_ADR(1), 0x005, 0x004,
|
||||
U8G_ESC_ADR(0), 0x000, 0x03d,
|
||||
U8G_ESC_ADR(1), 0x008, 0x008,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x050, /* Horizontal GRAM Start Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x051, /* Horizontal GRAM End Address: 239 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x0EF,
|
||||
U8G_ESC_ADR(0), 0x000, 0x052, /* Vertical GRAM Start Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x053, /* Vertical GRAM End Address: 319 */
|
||||
U8G_ESC_ADR(1), 0x001, 0x03F,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x060, /* Driver Output Control 2 */
|
||||
U8G_ESC_ADR(1), 0x0a7, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x061, /* Base Image Display Control: NDL,VLE, REV */
|
||||
U8G_ESC_ADR(1), 0x000, 0x001,
|
||||
U8G_ESC_ADR(0), 0x000, 0x06a, /* Vertical Scroll Control */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x080, /* Partial Image 1 Display Position */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x081, /* Partial Image 1 RAM Start Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x082, /* Partial Image 1 RAM End Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x083, /* Partial Image 2 Display Position */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x084, /* Partial Image 2 RAM Start Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x085, /* Partial Image 2 RAM End Address */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x090, /* Panel Interface Control 1 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x010,
|
||||
U8G_ESC_ADR(0), 0x000, 0x092, /* Panel Interface Control 2 */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000, /* 0x006, 0x000 */
|
||||
|
||||
U8G_ESC_ADR(0), 0x000, 0x007, /* Display Control 1: Operate, display ON */
|
||||
U8G_ESC_ADR(1), 0x001, 0x033,
|
||||
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
|
||||
/* write test pattern */
|
||||
U8G_ESC_ADR(0), 0x000, 0x020, /* Horizontal GRAM Address Set */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x021, /* Vertical GRAM Address Set */
|
||||
U8G_ESC_ADR(1), 0x000, 0x010,
|
||||
U8G_ESC_ADR(0), 0x000, 0x022, /* Write Data to GRAM */
|
||||
U8G_ESC_ADR(1), 0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
0x000, 0x000,
|
||||
0x0fe, 0x0fe,
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ili9325d_320x240_page_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_ADR(0), 0x000, 0x020, /* Horizontal GRAM Address Set */
|
||||
U8G_ESC_ADR(1), 0x000, 0x000,
|
||||
U8G_ESC_ADR(0), 0x000, 0x021, /* Vertical GRAM Address Set */
|
||||
U8G_ESC_ADR(1),
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* convert the internal RGB 332 to 65K high byte */
|
||||
static uint8_t u8g_dev_ili9325d_get_65K_high_byte(uint8_t color)
|
||||
{
|
||||
uint8_t h;
|
||||
h = color;
|
||||
h &= 0x0e0;
|
||||
h |= h>>3;
|
||||
h &= 0x0f8;
|
||||
color>>=2;
|
||||
color &= 7;
|
||||
h |= color;
|
||||
return h;
|
||||
}
|
||||
|
||||
/* convert the internal RGB 332 to 65K high byte */
|
||||
static uint8_t u8g_dev_ili9325d_get_65K_low_byte(uint8_t color)
|
||||
{
|
||||
uint8_t l;
|
||||
l = color;
|
||||
l <<= 3;
|
||||
color &= 3;
|
||||
color <<= 1;
|
||||
l |= color;
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_ili9325d_320x240_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
//for(;;)
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ili9325d_320x240_init_seq);
|
||||
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t y, j;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < pb->p.page_height; i ++ )
|
||||
{
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ili9325d_320x240_page_seq);
|
||||
u8g_WriteByte(u8g, dev, y >> 8 ); /* display ram (cursor) address high byte */
|
||||
u8g_WriteByte(u8g, dev, y & 255 ); /* display ram (cursor) address low byte */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0 );
|
||||
u8g_WriteByte(u8g, dev, 0x022 ); /* start gram data */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
|
||||
for( j = 0; j < pb->width; j++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ili9325d_get_65K_high_byte(*ptr) );
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ili9325d_get_65K_low_byte(*ptr) );
|
||||
|
||||
ptr++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_ili9325d_320x240_8h8_buf[WIDTH*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_ili9325d_320x240_8h8_pb U8G_NOCOMMON = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_ili9325d_320x240_8h8_buf};
|
||||
u8g_dev_t u8g_dev_ili9325d_320x240_8bit U8G_NOCOMMON = { u8g_dev_ili9325d_320x240_fn, &u8g_ili9325d_320x240_8h8_pb, u8g_com_arduino_port_d_wr_fn };
|
||||
//u8g_dev_t u8g_dev_ili9325d_320x240_8bit = { u8g_dev_ili9325d_320x240_fn, &u8g_ili9325d_320x240_8h8_pb, u8g_com_arduino_parallel_fn };
|
||||
|
||||
//U8G_PB_DEV(u8g_dev_ili9325d_320x240_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ili9325d_320x240_fn, U8G_COM_PARALLEL);
|
||||
|
||||
|
@ -1,110 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ks0108_128x64.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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.
|
||||
|
||||
|
||||
ADDRESS = 0 (Command Mode)
|
||||
0x03f Display On
|
||||
0x0c0 Start Display at line 0
|
||||
0x040 | y write to y address (y:0..63)
|
||||
0x0b8 | x write to page [0..7]
|
||||
|
||||
|
||||
u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
|
||||
u8g_Init8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_ks0108_128x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip 1 */
|
||||
0x03f, /* display on */
|
||||
0x0c0, /* start at line 0 */
|
||||
U8G_ESC_DLY(20), /* delay 20 ms */
|
||||
U8G_ESC_CS(2), /* enable chip 2 */
|
||||
0x03f, /* display on */
|
||||
0x0c0, /* start at line 0 */
|
||||
U8G_ESC_DLY(20), /* delay 20 ms */
|
||||
U8G_ESC_CS(0), /* disable all chips */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_ks0108_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ks0108_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 2);
|
||||
u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (KS0108b) */
|
||||
u8g_WriteByte(u8g, dev, 0x040 ); /* set address 0 */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, 64, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (KS0108b) */
|
||||
u8g_WriteByte(u8g, dev, 0x040 ); /* set address 0 */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, 64, 64+(uint8_t *)pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ks0108_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ks0108_128x64_fn, U8G_COM_PARALLEL);
|
||||
U8G_PB_DEV(u8g_dev_ks0108_128x64_fast, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ks0108_128x64_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
@ -1,147 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_lc7981_160x80.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 160
|
||||
#define HEIGHT 80
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/*
|
||||
code ideas:
|
||||
https://github.com/vsergeev/embedded-drivers/tree/master/avr-lc7981
|
||||
data sheets:
|
||||
http://www.lcd-module.de/eng/pdf/zubehoer/lc7981.pdf
|
||||
http://www.lcd-module.de/pdf/grafik/w160-6.pdf
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_lc7981_160x80_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x000, /* mode register */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x032, /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x001, /* character/bits per pixel pitch */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x007, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x002, /* number of chars/byte width of the screen */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8-1, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x003, /* time division */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x050, /* Oct 2015: Changed from 7f to 50 (1/80 duty cycle) */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x008, /* display start low */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x009, /* display start high */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_lc7981_160x80_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_160x80_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00a ); /* display ram (cursor) address low byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00b ); /* display ram (cursor) address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00c ); /* write data */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_lc7981_160x80_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_160x80_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
@ -1,145 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_lc7981_240x128.c
|
||||
|
||||
Hitachi Display SP14N002
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/*
|
||||
http://www.mark-products.com/graphics.htm#240x128%20Pixel%20Format
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_lc7981_240x128_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x000, /* mode register */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x032, /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x001, /* character/bits per pixel pitch */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x007, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x002, /* number of chars/byte width of the screen */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8-1, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x003, /* time division */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x07f, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x008, /* display start low */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x009, /* display start high */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_lc7981_240x128_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_240x128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00a ); /* display ram (cursor) address low byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00b ); /* display ram (cursor) address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00c ); /* write data */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_lc7981_240x128_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_240x128_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
@ -1,145 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_lc7981_240x64.c
|
||||
|
||||
Tested with Nan Ya LM_J6_003_
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/*
|
||||
http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_lc7981_240x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x000, /* mode register */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x032, /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x001, /* character/bits per pixel pitch */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x007, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x002, /* number of chars/byte width of the screen */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8-1, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x003, /* time division */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x07f, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x008, /* display start low */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x009, /* display start high */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_lc7981_240x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_240x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00a ); /* display ram (cursor) address low byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00b ); /* display ram (cursor) address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00c ); /* write data */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_lc7981_240x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_240x64_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
@ -1,151 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_lc7981_320x64.c
|
||||
|
||||
Note: Requires 16 bit mode (Must be enabled in u8g.h)
|
||||
|
||||
Tested with Varitronix MGLS32064-03.pdf
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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 "u8g.h"
|
||||
|
||||
#ifdef U8G_16BIT
|
||||
#define WIDTH 320
|
||||
#else
|
||||
#define WIDTH 240
|
||||
#endif
|
||||
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/*
|
||||
http://www.gaw.ru/pdf/lcd/lcm/Varitronix/graf/MGLS32064-03.pdf
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_lc7981_320x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x000, /* mode register */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x032, /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x001, /* character/bits per pixel pitch */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x007, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x002, /* number of chars/byte width of the screen */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8-1, /* 8 bits per pixel */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x003, /* time division */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x07f, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x008, /* display start low */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x009, /* display start high */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* */
|
||||
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_lc7981_320x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_320x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00a ); /* display ram (cursor) address low byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00b ); /* display ram (cursor) address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x00c ); /* write data */
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_lc7981_320x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_320x64_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
@ -1,232 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ld7032_60x32.c
|
||||
|
||||
60x32 OLED display
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
/* define width as 64, so that it is a multiple of 8 */
|
||||
#define WIDTH 64
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_ld7032_60x32_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_DLY(1), /* delay 1 ms */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x002, /* Dot Matrix Display ON/OFF */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001, /* ON */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x014, /* Dot Matrix Display Stand-by ON/OFF */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* ON */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x01a, /* Dot Matrix Frame Rate */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x004, /* special value for this OLED from manual */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x01d, /* Graphics Memory Writing Direction */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* reset default (right down, horizontal) */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x009, /* Display Direction */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* reset default (x,y: min --> max) */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x030, /* Display Size X */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* Column Start Output */
|
||||
0x03b, /* Column End Output */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x032, /* Display Size Y */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* Row Start Output */
|
||||
0x01f, /* Row End Output */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x010, /* Peak Pulse Width Set */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* 0 SCLK */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x016, /* Peak Pulse Delay Set */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* 0 SCLK */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x012, /* Dot Matrix Current Level Set */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x050, /* 0x050 * 1 uA = 80 uA */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x018, /* Pre-Charge Pulse Width */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x003, /* 3 SCLK */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x044, /* Pre-Charge Mode */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x002, /* Every Time */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x048, /* Row overlap timing */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x003, /* Pre-Charge + Peak Delay + Peak boot Timing */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x03f, /* VCC_R_SEL */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x011, /* ??? */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x03d, /* VSS selection */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* 2.8V */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x002, /* Dot Matrix Display ON/OFF */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001, /* ON */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x008, /* write data */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* use box commands to set start adr */
|
||||
static const uint8_t u8g_dev_ld7032_60x32_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x034, /* box x start */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* 0 */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x035, /* box x end */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x007, /* */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x037, /* box y end */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x01f, /* */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x036, /* box y start */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ld7032_60x32_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
/* ... */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ld7032_60x32_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
/* ... */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_ld7032_60x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ld7032_60x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ld7032_60x32_data_start);
|
||||
u8g_WriteByte(u8g, dev, pb->p.page_y0); /* y start */
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x008);
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ld7032_60x32_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ld7032_60x32_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ld7032_60x32_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ld7032_60x32_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ld7032_60x32_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ld7032_60x32_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ld7032_60x32_parallel, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ld7032_60x32_fn, U8G_COM_PARALLEL);
|
||||
U8G_PB_DEV(u8g_dev_ld7032_60x32_hw_usart_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ld7032_60x32_fn, U8G_COM_HW_USART_SPI);
|
||||
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_null.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
uint8_t u8g_dev_null(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL: /* most often used command */
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return 1;
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_pcd8544_84x48.c
|
||||
|
||||
Display: Nokia 84x48
|
||||
|
||||
Status: Tested with PCF8812 Display
|
||||
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 84
|
||||
#define HEIGHT 48
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_pcd8544_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x021, /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
||||
0x006, /* temp. control: b10 = 2 */
|
||||
0x013, /* bias system 1:48 */
|
||||
0x0c0, /* medium Vop */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal operation */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00d, /* display on, invert */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_pcd8544_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_pcd8544_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x008, /* display blank */
|
||||
0x024, /* power down (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_pcd8544_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_pcd8544_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set X address */
|
||||
u8g_WriteByte(u8g, dev, 0x040 | pb->p.page); /* set Y address */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
/* the contrast adjustment does not work, needs to be analysed */
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x021); /* command mode, extended function set */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | ( (*(uint8_t *)arg) >> 1 ) );
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_pcd8544_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_pcd8544_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_pcd8544_84x48_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_pcd8544_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_pcd8544_84x48_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_pcd8544_fn, U8G_COM_HW_SPI);
|
||||
|
@ -1,138 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_pcf8812_96x65.c
|
||||
|
||||
Display: Nokia 96x65
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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.
|
||||
|
||||
|
||||
|
||||
om6206 comaptible to pcf8812 ?
|
||||
|
||||
Status: Tested
|
||||
|
||||
|
||||
Display Controller Seen in
|
||||
LPH7366 (9 pins, 84x48) PCD8544 Nokia 5110 / 5120 / 5130 / 5160 / 6110 / 6150
|
||||
LPH7677 (8 pins, 84x48) PCD8544 Nokia 3210
|
||||
LPH7779 (8 pins, 84x48) PCD8544 Nokia 3310 / 3315 / 3330 / 3110, also 3410?
|
||||
??? PCD8544 Nokia 5110 / 6110
|
||||
LPH7690 ? (96x65) PCF8455/OM6202 Nokia 3410
|
||||
LPH7690 ? (96x65?) SED1565/S1D15605 Nokia 7110 / 3510?
|
||||
LPH7690 ??? Nokia 6210
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 96
|
||||
#define HEIGHT 65
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_pcf8812_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x021, /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
||||
0x006, /* temp. control: b10 = 2 */
|
||||
0x013, /* bias system 1:48 */
|
||||
0x080 | 0x040, /* medium Vop */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal operation */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00d, /* display on, invert */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_pcf8812_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_pcf8812_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set X address */
|
||||
u8g_WriteByte(u8g, dev, 0x040 | pb->p.page); /* set Y address */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
|
||||
/* mirrored output, not tested*/
|
||||
/*
|
||||
{
|
||||
uint8_t i = pb->width;
|
||||
while( i > 0 )
|
||||
{
|
||||
i--;
|
||||
u8g_WriteByte(u8g, dev, ((unsigned char *)pb->buf)[i] );
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
/* the contrast adjustment does not work, needs to be analysed */
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x021); /* command mode, extended function set */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | ( (*(uint8_t *)arg) >> 1 ) );
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
/* u8g_com_arduino_sw_spi_fn does not work, too fast??? */
|
||||
U8G_PB_DEV(u8g_dev_pcf8812_96x65_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_pcf8812_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_pcf8812_96x65_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_pcf8812_fn, U8G_COM_HW_SPI);
|
@ -1,107 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_sbn1661_122x32.c
|
||||
|
||||
WG12232 display with 2xSBN1661 / SED1520 controller (122x32 display)
|
||||
At the moment only available in the Arduino Environment
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 122
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_sbn1661_122x32_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip 1 */
|
||||
0x0af, /* display on */
|
||||
0x0c0, /* display start at line 0 */
|
||||
0x0a0, /* a0: ADC forward, a1: ADC reverse */
|
||||
0x0a9, /* a8: 1/16, a9: 1/32 duty */
|
||||
U8G_ESC_CS(2), /* enable chip 2 */
|
||||
0x0af, /* display on */
|
||||
0x0c0, /* display start at line 0 */
|
||||
0x0a0, /* a0: ADC forward, a1: ADC reverse */
|
||||
0x0a9, /* a8: 1/16, a9: 1/32 duty */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
|
||||
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_sbn1661_122x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_sbn1661_122x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (SBN1661/SED1520) */
|
||||
u8g_WriteByte(u8g, dev, 0x000 ); /* set X address */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/2, pb->buf);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 2);
|
||||
u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (SBN1661/SED1520) */
|
||||
u8g_WriteByte(u8g, dev, 0x000 ); /* set X address */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/2, WIDTH/2+(uint8_t *)pb->buf);
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
/* u8g_com_arduino_sw_spi_fn does not work, too fast??? */
|
||||
U8G_PB_DEV(u8g_dev_sbn1661_122x32 , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sbn1661_122x32_fn, u8g_com_arduino_no_en_parallel_fn);
|
@ -1,303 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1306_128x32.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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.
|
||||
|
||||
|
||||
23 Feb 2013: Fixed, Issue 147
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/* init sequence adafruit 128x32 OLED (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x32_adafruit1_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x010, /* [1] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x000, /* */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x09f, /* [1] set contrast control */
|
||||
0x0d9, 0x022, /* [1] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* init sequence adafruit 128x32 OLED (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x32_adafruit2_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x000, /* */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x0cf, /* [2] set contrast control */
|
||||
0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* init sequence adafruit 128x32 OLED (TESTED - WORKING 23.02.13), like adafruit3, but with page addressing mode */
|
||||
static const uint8_t u8g_dev_ssd1306_128x32_adafruit3_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x01f, /* Feb 23, 2013: 128x32 OLED: 0x01f, 128x32 OLED 0x03f */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x002, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), Feb 23, 2013: 128x32 OLED: 0x002, 128x32 OLED 0x012 */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x002, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x0cf, /* [2] set contrast control */
|
||||
0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* init sequence Univision datasheet (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x32_univision_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* multiplex ratio */
|
||||
0x0d3, 0x000, /* display offset */
|
||||
0x040, /* start line */
|
||||
0x08d, 0x010, /* charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x09f, /* set contrast control */
|
||||
0x0d9, 0x022, /* pre-charge period */
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
0x022, 0x000, /* page addressing mode WRONG: 3 byte cmd! */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* select one init sequence here */
|
||||
//define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_univision_init_seq
|
||||
//define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_adafruit1_init_seq
|
||||
//define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_adafruit2_init_seq
|
||||
#define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_adafruit3_init_seq
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ssd1306_128x32_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr. to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr. to 4 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_ssd1306_128x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x32_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); /* 11 Jul 2015: fixed contrast calculation */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1306_128x32_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x32_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2)); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x32_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2+1)); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); /* 11 Jul 2015: fixed contrast calculation */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x32_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x32_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x32_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x32_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x32_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x32_fn, U8G_COM_SSD_I2C);
|
||||
|
||||
uint8_t u8g_dev_ssd1306_128x32_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1306_128x32_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_128x32_2x_buf};
|
||||
u8g_dev_t u8g_dev_ssd1306_128x32_2x_sw_spi = { u8g_dev_ssd1306_128x32_2x_fn, &u8g_dev_ssd1306_128x32_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1306_128x32_2x_hw_spi = { u8g_dev_ssd1306_128x32_2x_fn, &u8g_dev_ssd1306_128x32_2x_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1306_128x32_2x_i2c = { u8g_dev_ssd1306_128x32_2x_fn, &u8g_dev_ssd1306_128x32_2x_pb, U8G_COM_SSD_I2C };
|
@ -1,457 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1306_128x64.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/* init sequence adafruit 128x64 OLED (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x64_adafruit1_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x010, /* [1] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x000, /* */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x09f, /* [1] set contrast control */
|
||||
0x0d9, 0x022, /* [1] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* init sequence adafruit 128x64 OLED (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x64_adafruit2_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x000, /* */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x0cf, /* [2] set contrast control */
|
||||
0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* init sequence adafruit 128x64 OLED (NOT TESTED), like adafruit3, but with page addressing mode */
|
||||
static const uint8_t u8g_dev_ssd1306_128x64_adafruit3_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x014, /* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
0x020, 0x002, /* 2012-05-27: page addressing mode */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x0cf, /* [2] set contrast control */
|
||||
0x0d9, 0x0f1, /* [2] pre-charge period 0x022/f1*/
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* init sequence Univision datasheet (NOT TESTED) */
|
||||
static const uint8_t u8g_dev_ssd1306_128x64_univision_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x03f, /* multiplex ratio */
|
||||
0x0d3, 0x000, /* display offset */
|
||||
0x040, /* start line */
|
||||
0x08d, 0x010, /* charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
|
||||
0x081, 0x09f, /* set contrast control */
|
||||
0x0d9, 0x022, /* pre-charge period */
|
||||
0x0db, 0x040, /* vcomh deselect level */
|
||||
0x022, 0x000, /* page addressing mode WRONG: 3 byte cmd! */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* select one init sequence here */
|
||||
//#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_univision_init_seq
|
||||
//#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit1_init_seq
|
||||
// 26. Apr 2014: in this thead: http://forum.arduino.cc/index.php?topic=234930.msg1696754;topicseen#msg1696754
|
||||
// it is mentiond, that adafruit2_init_seq works better --> this will be used by the ssd1306_adafruit device
|
||||
//#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit2_init_seq
|
||||
|
||||
#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit3_init_seq
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ssd1306_128x64_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* the sh1106 is compatible to the ssd1306, but is 132x64. display seems to be centered */
|
||||
static const uint8_t u8g_dev_sh1106_128x64_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x002, /* set lower 4 bit of the col adr to 2 (centered display with sh1106) */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_ssd1306_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_adafruit2_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
{
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x81);
|
||||
u8g_WriteByte(u8g, dev, *(uint8_t *) arg);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1306_adafruit_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
{
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x81);
|
||||
u8g_WriteByte(u8g, dev, *(uint8_t *) arg);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_sh1106_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_128x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
{
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x81);
|
||||
u8g_WriteByte(u8g, dev, *(uint8_t *) arg);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1306_128x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2)); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2+1)); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
{
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x81);
|
||||
u8g_WriteByte(u8g, dev, *(uint8_t *) arg);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_sh1106_128x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_128x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2)); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_sh1106_128x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2+1)); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
{
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x81);
|
||||
u8g_WriteByte(u8g, dev, *(uint8_t *) arg);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SSD_I2C);
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_adafruit_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_adafruit_128x64_fn, U8G_COM_SSD_I2C);
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1306_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1306_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_128x64_2x_buf};
|
||||
u8g_dev_t u8g_dev_ssd1306_128x64_2x_sw_spi = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1306_128x64_2x_hw_spi = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1306_128x64_2x_i2c = { u8g_dev_ssd1306_128x64_2x_fn, &u8g_dev_ssd1306_128x64_2x_pb, U8G_COM_SSD_I2C };
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_sh1106_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_sh1106_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_sh1106_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sh1106_128x64_fn, U8G_COM_SSD_I2C);
|
||||
|
||||
uint8_t u8g_dev_sh1106_128x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_sh1106_128x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_sh1106_128x64_2x_buf};
|
||||
u8g_dev_t u8g_dev_sh1106_128x64_2x_sw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_sh1106_128x64_2x_hw_spi = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_sh1106_128x64_2x_i2c = { u8g_dev_sh1106_128x64_2x_fn, &u8g_dev_sh1106_128x64_2x_pb, U8G_COM_SSD_I2C };
|
||||
|
@ -1,201 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1306_64x48.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 64
|
||||
#define HEIGHT 48
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
|
||||
/* init sequence buydisplay.com 0.66" 64x48 OLED */
|
||||
/* http://www.buydisplay.com/download/manual/ER-OLED0.66-1_Series_Datasheet.pdf */
|
||||
static const uint8_t u8g_dev_ssd1306_64x48_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0d5, 0x080, /* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
|
||||
0x0a8, 0x02f, /* Multiplex Ration, Jul 12, 2015: From 0.66" OLED datasheet */
|
||||
|
||||
0x0d3, 0x000, /* */
|
||||
|
||||
0x040, /* start line */
|
||||
|
||||
0x08d, 0x014, /* charge pump setting (p62): 0x014 enable, 0x010 disable */
|
||||
|
||||
//0x020, 0x002, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), Feb 23, 2013: 64x48 OLED: 0x002, 64x48 OLED 0x012 */
|
||||
0x0a1, /* segment remap a0/a1*/
|
||||
0x0c8, /* c0: scan dir normal, c8: reverse */
|
||||
0x0da, 0x012, /* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), Jul 12, 2015: From 0.66" OLED datasheet */
|
||||
0x081, 0x0cf, /* set contrast control */
|
||||
0x0d9, 0x022, /* pre-charge period 0x022/f1, from 0.66" OLED datasheet */
|
||||
0x0db, 0x000, /* vcomh deselect level, from 0.66" OLED datasheet */
|
||||
|
||||
0x02e, /* 2012-05-27: Deactivate scroll */
|
||||
0x0a4, /* output ram to display */
|
||||
0x0a6, /* none inverted normal display mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ssd1306_64x48_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010+2, /* set upper 4 bit of the col adr. to 0, 0.66" OLED starts with offset 32 */
|
||||
0x000, /* set lower 4 bit of the col adr. to 4 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_ssd1306_64x48_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_64x48_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_64x48_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); /* 11 Jul 2015: fixed contrast calculation */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1306_64x48_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_64x48_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_64x48_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2)); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_64x48_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (pb->p.page*2+1)); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); /* 11 Jul 2015: fixed contrast calculation */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_64x48_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_64x48_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_64x48_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_64x48_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1306_64x48_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_64x48_fn, U8G_COM_SSD_I2C);
|
||||
|
||||
uint8_t u8g_dev_ssd1306_64x48_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1306_64x48_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1306_64x48_2x_buf};
|
||||
u8g_dev_t u8g_dev_ssd1306_64x48_2x_sw_spi = { u8g_dev_ssd1306_64x48_2x_fn, &u8g_dev_ssd1306_64x48_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1306_64x48_2x_hw_spi = { u8g_dev_ssd1306_64x48_2x_fn, &u8g_dev_ssd1306_64x48_2x_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1306_64x48_2x_i2c = { u8g_dev_ssd1306_64x48_2x_fn, &u8g_dev_ssd1306_64x48_2x_pb, U8G_COM_SSD_I2C };
|
@ -1,142 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1309_128x64.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/* ssd1309 ini sequence*/
|
||||
static const uint8_t u8g_dev_ssd1309_128x64_init_seq[] PROGMEM={
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0xfd,0x12, /*Command Lock */
|
||||
0xae, /*Set Display Off */
|
||||
0xd5,0xa0, /*set Display Clock Divide Ratio/Oscillator Frequency */
|
||||
0xa8,0x3f, /*Set Multiplex Ratio */
|
||||
0x3d,0x00, /*Set Display Offset*/
|
||||
0x40, /*Set Display Start Line*/
|
||||
0xa1, /*Set Segment Re-Map*/
|
||||
0xc8, /*Set COM Output Scan Direction*/
|
||||
0xda,0x12, /*Set COM Pins Hardware Configuration*/
|
||||
0x81,0xdf, /*Set Current Control */
|
||||
0xd9,0x82, /*Set Pre-Charge Period */
|
||||
0xdb,0x34, /*Set VCOMH Deselect Level */
|
||||
0xa4, /*Set Entire Display On/Off */
|
||||
0xa6, /*Set Normal/Inverse Display*/
|
||||
U8G_ESC_VCC(1), /*Power up VCC & Stabilized */
|
||||
U8G_ESC_DLY(50),
|
||||
0xaf, /*Set Display On */
|
||||
U8G_ESC_DLY(50),
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
/* select one init sequence here */
|
||||
#define u8g_dev_ssd1309_128x64_init_seq u8g_dev_ssd1309_128x64_init_seq
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ssd1309_128x64_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 4 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_ssd1309_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); /* 11 Jul 2015: fixed contrast calculation */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1309_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1309_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1309_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_SSD_I2C);
|
@ -1,338 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1322_nhd31oled_bw.c
|
||||
|
||||
1-Bit (BW) Driver for SSD1322 Controller (OLED Display)
|
||||
Tested with NHD-3.12-25664
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/* width must be multiple of 8, largest value is 248 unless u8g 16 bit mode is enabled */
|
||||
#if defined(U8G_16BIT)
|
||||
#define WIDTH 256
|
||||
#else
|
||||
#define WIDTH 248
|
||||
#endif
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/*
|
||||
http://www.newhavendisplay.com/app_notes/OLED_25664.txt
|
||||
http://www.newhavendisplay.com/forum/viewtopic.php?f=15&t=3758
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_ssd1322_1bit_nhd_312_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0fd, /* lock command */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x012, /* unlock */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b3,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x091, /* set display clock divide ratio/oscillator frequency (set clock as 80 frames/sec) */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ca, /* multiplex ratio */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x03f, /* 1/64 Duty (0x0F~0x3F) */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a2,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* display offset, shift mapping ram counter */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a1,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* display start line */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a0, /* Set Re-Map / Dual COM Line Mode */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x014, /* was 0x014 */
|
||||
0x011, /* was 0x011 */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ab,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001, /* Enable Internal VDD Regulator */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b4, /* Display Enhancement A */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x0a0,
|
||||
0x005|0x0fd,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0c1, /* contrast */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x09f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0c7, /* Set Scale Factor of Segment Output Current Control */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x00f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b9, /* linear gray scale */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b1, /* Phase 1 (Reset) & Phase 2 (Pre-Charge) Period Adjustment */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x0e2,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0d1, /* Display Enhancement B */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x082|0x020,
|
||||
0x020,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0bb, /* precharge voltage */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x01f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b6, /* precharge period */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x008,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0be, /* vcomh */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x007,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a6, /* normal display */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a9, /* exit partial display */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1322_1bit_nhd_312_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x01c, /* start at column 0 */
|
||||
0x05b, /* end column */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static void u8g_dev_ssd1322_1bit_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
|
||||
{
|
||||
uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
|
||||
row += delta_row;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_1bit_nhd_312_prepare_page_seq);
|
||||
|
||||
u8g_WriteByte(u8g, dev, row); /* start at the selected row */
|
||||
u8g_WriteByte(u8g, dev, row+1); /* end within the selected row */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode mode */
|
||||
u8g_WriteByte(u8g, dev, 0x05c); /* write to ram */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_1bit_nhd_312_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 3;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1322_1bit_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
#endif
|
||||
u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
#endif
|
||||
u8g_MicroDelay(); // for DUE?
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_MicroDelay(); // for DUE?
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_1bit_nhd_312_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 3;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1322_1bit_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
#endif
|
||||
u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
u8g_WriteByte(u8g, dev, 0x0ff);
|
||||
#endif
|
||||
u8g_MicroDelay(); // for DUE?
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x0c1); /* 21 May 2013, fixed contrast command */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_bw_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1322_nhd31oled_bw_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_bw_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1322_nhd31oled_bw_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_bw_parallel , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1322_nhd31oled_bw_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
#define DWIDTH (WIDTH*2)
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_2x_bw_buf[DWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1322_nhd31oled_2x_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1322_nhd31oled_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_sw_spi = { u8g_dev_ssd1322_nhd31oled_2x_bw_fn, &u8g_dev_ssd1322_nhd31oled_2x_bw_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi = { u8g_dev_ssd1322_nhd31oled_2x_bw_fn, &u8g_dev_ssd1322_nhd31oled_2x_bw_pb, U8G_COM_HW_SPI };
|
||||
|
@ -1,338 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1322_nhd31oled_gr.c
|
||||
|
||||
2-Bit (4L) Driver for SSD1322 Controller (OLED Display)
|
||||
Tested with NHD-3.12-25664
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/* width must be multiple of 8, largest value is 248 unless u8g 16 bit mode is enabled */
|
||||
#if defined(U8G_16BIT)
|
||||
#define WIDTH 256
|
||||
#else
|
||||
#define WIDTH 248
|
||||
#endif
|
||||
#define HEIGHT 64
|
||||
//#define PAGE_HEIGHT 8
|
||||
|
||||
/*
|
||||
http://www.newhavendisplay.com/app_notes/OLED_25664.txt
|
||||
http://www.newhavendisplay.com/forum/viewtopic.php?f=15&t=3758
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_ssd1322_2bit_nhd_312_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0fd, /* lock command */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x012, /* unlock */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b3,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x091, /* set display clock divide ratio/oscillator frequency (set clock as 80 frames/sec) */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ca, /* multiplex ratio */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x03f, /* 1/64 Duty (0x0F~0x3F) */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a2,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* display offset, shift mapping ram counter */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a1,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* display start line */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a0, /* Set Re-Map / Dual COM Line Mode */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x014, /* was 0x014 */
|
||||
0x011, /* was 0x011 */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0ab,
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001, /* Enable Internal VDD Regulator */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b4, /* Display Enhancement A */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x0a0,
|
||||
0x005|0x0fd,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0c1, /* contrast */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x09f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0c7, /* Set Scale Factor of Segment Output Current Control */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x00f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b9, /* linear gray scale */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b1, /* Phase 1 (Reset) & Phase 2 (Pre-Charge) Period Adjustment */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x0e2,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0d1, /* Display Enhancement B */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x082|0x020,
|
||||
0x020,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0bb, /* precharge voltage */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x01f,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0b6, /* precharge period */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x008,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0be, /* vcomh */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x007,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a6, /* normal display */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0a9, /* exit partial display */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x0af, /* display on */
|
||||
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1322_2bit_nhd_312_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x01c, /* start at column 0 */
|
||||
0x05b, /* end column */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static void u8g_dev_ssd1322_2bit_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
|
||||
{
|
||||
uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
|
||||
row += delta_row;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_2bit_nhd_312_prepare_page_seq);
|
||||
|
||||
u8g_WriteByte(u8g, dev, row); /* start at the selected row */
|
||||
u8g_WriteByte(u8g, dev, row+1); /* end within the selected row */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode mode */
|
||||
u8g_WriteByte(u8g, dev, 0x05c); /* write to ram */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_2bit_nhd_312_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 2;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1322_2bit_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
#endif
|
||||
u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
#endif
|
||||
u8g_MicroDelay(); // for DUE?
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_MicroDelay(); // for DUE?
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8h2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_2bit_nhd_312_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 2; /* 23 Oct 2013, changed to 2 */
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1322_2bit_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
#endif
|
||||
u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
|
||||
#if !defined(U8G_16BIT)
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
u8g_WriteByte(u8g, dev, 0x00);
|
||||
#endif
|
||||
u8g_MicroDelay(); // for DUE?
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16h2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_gr_sw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1322_nhd31oled_gr_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_gr_hw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1322_nhd31oled_gr_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_gr_parallel , WIDTH, HEIGHT, 4, u8g_dev_ssd1322_nhd31oled_gr_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
||||
#define DWIDTH (WIDTH*2)
|
||||
uint8_t u8g_dev_ssd1322_nhd31oled_2x_gr_buf[DWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1322_nhd31oled_2x_gr_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1322_nhd31oled_2x_gr_buf};
|
||||
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_sw_spi = { u8g_dev_ssd1322_nhd31oled_2x_gr_fn, &u8g_dev_ssd1322_nhd31oled_2x_gr_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi = { u8g_dev_ssd1322_nhd31oled_2x_gr_fn, &u8g_dev_ssd1322_nhd31oled_2x_gr_pb, U8G_COM_HW_SPI };
|
||||
|
@ -1,263 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1325_nhd27oled_bw.c
|
||||
|
||||
1-Bit (BW) Driver for SSD1325 Controller (OLED Display)
|
||||
Tested with NHD-2.7-12864UCY3
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#ifdef OBSOLETE_CODE
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
|
||||
static const uint8_t u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0b3, 0x091, /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
0x0a8, 0x03f, /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
0x0a2, 0x04c, /* display offset, shift mapping ram counter */
|
||||
0x0a1, 0x000, /* display start line */
|
||||
0x0ad, 0x002, /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
0x0a0, 0x056, /* remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
|
||||
0x086, /* full current range (0x084, 0x085, 0x086) */
|
||||
0x0b8, /* set gray scale table */
|
||||
0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
|
||||
0x081, 0x070, /* contrast, brightness, 0..128, Newhaven: 0x040 */
|
||||
0x0b2, 0x051, /* frame frequency (row period) */
|
||||
0x0b1, 0x055, /* phase length */
|
||||
0x0bc, 0x010, /* pre-charge voltage level */
|
||||
0x0b4, 0x002, /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0b0, 0x028, /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0be, 0x01c, /* VCOMH voltage */
|
||||
0x0bf, 0x002|0x00d, /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0a5, /* all pixel on */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display mode */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
0x000, /* start at column 0 */
|
||||
0x03f, /* end at column 63 (which is y == 127), because there are two pixel in one column */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static void u8g_dev_ssd1325_1bit_prepare_page(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_prepare_page_seq);
|
||||
|
||||
page <<= 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 7;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1325_1bit_2x_prepare_page(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_prepare_page_seq);
|
||||
|
||||
page <<= 1;
|
||||
page += is_odd;
|
||||
|
||||
page <<= 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 7;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
/* assumes row autoincrement and activated nibble remap */
|
||||
#ifdef OLD
|
||||
static void _OLD_u8g_dev_ssd1325_1bit_write_16_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
|
||||
{
|
||||
uint8_t d, cnt;
|
||||
cnt = 8;
|
||||
do
|
||||
{
|
||||
d = 0;
|
||||
if ( left & 1 )
|
||||
d |= 0x0f0;
|
||||
if ( right & 1 )
|
||||
d |= 0x00f;
|
||||
u8g_WriteByte(u8g, dev, d);
|
||||
left >>= 1;
|
||||
right >>= 1;
|
||||
cnt--;
|
||||
}while ( cnt > 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
static void u8g_dev_ssd1325_1bit_write_16_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
|
||||
{
|
||||
uint8_t d, cnt;
|
||||
static uint8_t buf[8];
|
||||
cnt = 8;
|
||||
do
|
||||
{
|
||||
d = 0;
|
||||
if ( left & 128 )
|
||||
d |= 0x0f0;
|
||||
if ( right & 128 )
|
||||
d |= 0x00f;
|
||||
cnt--;
|
||||
buf[cnt] = d;
|
||||
left <<= 1;
|
||||
right <<= 1;
|
||||
}while ( cnt > 0 );
|
||||
u8g_WriteSequence(u8g, dev, 8, buf);
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1325_1bit_write_buffer(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t cnt, left, right;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
ptr = pb->buf;
|
||||
cnt = pb->width;
|
||||
if ( is_odd )
|
||||
ptr += cnt;
|
||||
cnt >>= 1;
|
||||
do
|
||||
{
|
||||
left = *ptr++;
|
||||
right = *ptr++;
|
||||
u8g_dev_ssd1325_1bit_write_16_pixel(u8g, dev, left, right);
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1325_nhd27oled_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1325_1bit_prepare_page(u8g, dev);
|
||||
u8g_dev_ssd1325_1bit_write_buffer(u8g, dev, 0);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1325_1bit_2x_prepare_page(u8g, dev, 0);
|
||||
u8g_dev_ssd1325_1bit_write_buffer(u8g, dev, 0);
|
||||
u8g_dev_ssd1325_1bit_2x_prepare_page(u8g, dev, 1);
|
||||
u8g_dev_ssd1325_1bit_write_buffer(u8g, dev, 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
/* disabled, see bw_new.c */
|
||||
/*
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_parallel , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_FAST_PARALLEL);
|
||||
*/
|
||||
|
||||
/*
|
||||
uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1325_nhd27oled_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_parallel = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_FAST_PARALLEL };
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
@ -1,232 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1325_nhd27oled_bw.c
|
||||
|
||||
1-Bit (BW) Driver for SSD1325 Controller (OLED Display)
|
||||
Horizontal architecture, completly rewritten
|
||||
Tested with NHD-2.7-12864UCY3
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/* width must be multiple of 8, largest value is 248 unless u8g 16 bit mode is enabled */
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
|
||||
/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
|
||||
static const uint8_t u8g_dev_ssd1325_nhd_27_12864_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0b3, 0x091, /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
0x0a8, 0x03f, /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
0x0a2, 0x04c, /* display offset, shift mapping ram counter */
|
||||
0x0a1, 0x000, /* display start line */
|
||||
0x0ad, 0x002, /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
0x0a0, 0x052, /* remap configuration, horizontal address increment (bit 2 = 0), enable nibble remap (upper nibble is left, bit 1 = 1) */
|
||||
0x086, /* full current range (0x084, 0x085, 0x086) */
|
||||
0x0b8, /* set gray scale table */
|
||||
0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
|
||||
|
||||
0x081, 0x070, /* contrast, brightness, 0..128, Newhaven: 0x040 */
|
||||
0x0b2, 0x051, /* frame frequency (row period) */
|
||||
0x0b1, 0x055, /* phase length */
|
||||
0x0bc, 0x010, /* pre-charge voltage level */
|
||||
0x0b4, 0x002, /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0b0, 0x028, /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0be, 0x01c, /* VCOMH voltage */
|
||||
0x0bf, 0x002|0x00d, /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0a4, /* normal display mode */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1325_prepare_row_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
0x000, /* start at column 0 */
|
||||
0x03f, /* end at column 63 (which is y == 127), because there are two pixel in one column */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static void u8g_dev_ssd1325_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
|
||||
{
|
||||
uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
|
||||
row += delta_row;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_prepare_row_seq);
|
||||
|
||||
u8g_WriteByte(u8g, dev, row); /* start at the selected row */
|
||||
u8g_WriteByte(u8g, dev, row+1); /* end within the selected row */
|
||||
|
||||
//u8g_SetAddress(u8g, dev, 0); /* instruction mode mode */
|
||||
//u8g_WriteByte(u8g, dev, 0x05c); /* write to ram */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
//case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
// return u8g_pb_IsIntersection((u8g_pb_t *)(dev->dev_mem), (u8g_dev_arg_bbx_t *)arg);
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_nhd_27_12864_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 3;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1325_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_nhd_27_12864_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 3;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1325_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_sw_spi , WIDTH, HEIGHT, 8, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_hw_spi , WIDTH, HEIGHT, 8, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_parallel , WIDTH, HEIGHT, 8, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1325_nhd27oled_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_parallel = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_FAST_PARALLEL };
|
||||
|
@ -1,255 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1325_nhd27oled_gr.c
|
||||
|
||||
2-Bit (gray level) Driver for SSD1325 Controller (OLED Display)
|
||||
Tested with NHD-2.7-12864UCY3
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#ifdef OBSOLETE_CODE
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
|
||||
/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
|
||||
static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0b3, 0x091, /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
0x0a8, 0x03f, /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
0x0a2, 0x04c, /* display offset, shift mapping ram counter */
|
||||
0x0a1, 0x000, /* display start line */
|
||||
0x0ad, 0x002, /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
0x0a0, 0x056, /* remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
|
||||
0x086, /* full current range (0x084, 0x085, 0x086) */
|
||||
0x0b8, /* set gray scale table */
|
||||
//0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
|
||||
0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x077, 0x077, // 4L mode uses 0, 2, 4, 7
|
||||
0x081, 0x070, /* contrast, brightness, 0..128, Newhaven: 0x040 */
|
||||
0x0b2, 0x051, /* frame frequency (row period) */
|
||||
0x0b1, 0x055, /* phase length */
|
||||
0x0bc, 0x010, /* pre-charge voltage level */
|
||||
0x0b4, 0x002, /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0b0, 0x028, /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0be, 0x01c, /* VCOMH voltage */
|
||||
0x0bf, 0x002|0x00d, /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0a5, /* all pixel on */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display mode */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
0x000, /* start at column 0 */
|
||||
0x03f, /* end at column 63 (which is y == 127), because there are two pixel in one column */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static void u8g_dev_ssd1325_2bit_prepare_page(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq);
|
||||
|
||||
page <<= 2;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1325_2bit_2x_prepare_page(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq);
|
||||
|
||||
page <<= 1;
|
||||
page += is_odd;
|
||||
|
||||
|
||||
page <<= 2;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
/* assumes row autoincrement and activated nibble remap */
|
||||
static void u8g_dev_ssd1325_2bit_write_4_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
|
||||
{
|
||||
uint8_t d, tmp, cnt;
|
||||
cnt = 4;
|
||||
do
|
||||
{
|
||||
d = left;
|
||||
d &= 3;
|
||||
d <<= 4;
|
||||
tmp = right;
|
||||
tmp &= 3;
|
||||
d |= tmp;
|
||||
d <<= 2;
|
||||
u8g_WriteByte(u8g, dev, d);
|
||||
left >>= 2;
|
||||
right >>= 2;
|
||||
cnt--;
|
||||
}while ( cnt > 0 );
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1325_2bit_write_buffer(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t cnt, left, right;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
cnt = pb->width;
|
||||
cnt >>= 1;
|
||||
ptr = pb->buf;
|
||||
do
|
||||
{
|
||||
left = *ptr++;
|
||||
right = *ptr++;
|
||||
u8g_dev_ssd1325_2bit_write_4_pixel(u8g, dev, left, right);
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1325_2bit_2x_write_buffer(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t cnt, left, right;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
ptr = pb->buf;
|
||||
cnt = pb->width;
|
||||
if ( is_odd )
|
||||
ptr += cnt;
|
||||
cnt >>= 1;
|
||||
do
|
||||
{
|
||||
left = *ptr++;
|
||||
right = *ptr++;
|
||||
u8g_dev_ssd1325_2bit_write_4_pixel(u8g, dev, left, right);
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
}
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1325_2bit_prepare_page(u8g, dev);
|
||||
u8g_dev_ssd1325_2bit_write_buffer(u8g, dev);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1325_2bit_2x_prepare_page(u8g, dev, 0);
|
||||
u8g_dev_ssd1325_2bit_2x_write_buffer(u8g, dev, 0);
|
||||
u8g_dev_ssd1325_2bit_2x_prepare_page(u8g, dev, 1);
|
||||
u8g_dev_ssd1325_2bit_2x_write_buffer(u8g, dev, 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
//U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_sw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_SW_SPI);
|
||||
//U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_hw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_HW_SPI);
|
||||
|
||||
//uint8_t u8g_dev_ssd1325_nhd27oled_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
//u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1325_nhd27oled_2x_buf};
|
||||
//u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_SW_SPI };
|
||||
//u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_HW_SPI };
|
||||
|
||||
|
||||
#endif /* OBSOLETE_CODE */
|
@ -1,228 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1325_nhd27oled_gr.c
|
||||
|
||||
2-Bit (gray level) Driver for SSD1325 Controller (OLED Display)
|
||||
Rewritten with new architecture
|
||||
Tested with NHD-2.7-12864UCY3
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
|
||||
/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
|
||||
static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0b3, 0x091, /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
|
||||
0x0a8, 0x03f, /* multiplex ratio: 0x03f * 1/64 duty */
|
||||
0x0a2, 0x04c, /* display offset, shift mapping ram counter */
|
||||
0x0a1, 0x000, /* display start line */
|
||||
0x0ad, 0x002, /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
0x0a0, 0x052, /* remap configuration, horizontal address increment (bit 2 = 0), enable nibble remap (upper nibble is left, bit 1 = 1), old values: 0x0a0 0x0a6 */
|
||||
0x086, /* full current range (0x084, 0x085, 0x086) */
|
||||
0x0b8, /* set gray scale table */
|
||||
//0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
|
||||
0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x077, 0x077, // 4L mode uses 0, 2, 4, 7
|
||||
0x081, 0x070, /* contrast, brightness, 0..128, Newhaven: 0x040 */
|
||||
0x0b2, 0x051, /* frame frequency (row period) */
|
||||
0x0b1, 0x055, /* phase length */
|
||||
0x0bc, 0x010, /* pre-charge voltage level */
|
||||
0x0b4, 0x002, /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0b0, 0x028, /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0be, 0x01c, /* VCOMH voltage */
|
||||
0x0bf, 0x002|0x00d, /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0a4, /* normal display mode */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
0x000, /* start at column 0 */
|
||||
0x03f, /* end at column 63 (which is y == 127), because there are two pixel in one column */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static void u8g_dev_ssd1325_gr_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
|
||||
{
|
||||
uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
|
||||
row += delta_row;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq);
|
||||
|
||||
u8g_WriteByte(u8g, dev, row); /* start at the selected row */
|
||||
u8g_WriteByte(u8g, dev, row+1); /* end within the selected row */
|
||||
|
||||
//u8g_SetAddress(u8g, dev, 0); /* instruction mode mode */
|
||||
//u8g_WriteByte(u8g, dev, 0x05c); /* write to ram */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ae, /* display off */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 2;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1325_gr_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8h2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static uint8_t u8g_dev_ssd1325_nhd27oled_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *p = pb->buf;
|
||||
u8g_uint_t cnt;
|
||||
cnt = pb->width;
|
||||
cnt >>= 2;
|
||||
|
||||
for( i = 0; i < pb->p.page_height; i++ )
|
||||
{
|
||||
u8g_dev_ssd1325_gr_prepare_row(u8g, dev, i); /* this will also enable chip select */
|
||||
u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
p+=cnt;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16h2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_sw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_hw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_parallel , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
uint8_t u8g_dev_ssd1325_nhd27oled_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1325_nhd27oled_2x_buf};
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_HW_SPI };
|
@ -1,299 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1327_96x96_gr.c
|
||||
|
||||
2-Bit (graylevel) Driver for SSD1327 Controller (OLED Display)
|
||||
Tested with Seedstudio 96x96 Oled (LY120)
|
||||
http://www.seeedstudio.com/wiki/index.php?title=Twig_-_OLED_96x96
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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.
|
||||
|
||||
SSD130x Monochrom OLED Controller
|
||||
SSD131x Character OLED Controller
|
||||
SSD132x Graylevel OLED Controller
|
||||
SSD1331 Color OLED Controller
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 96
|
||||
#define HEIGHT 96
|
||||
#define XOFFSET 8
|
||||
|
||||
/*
|
||||
http://www.seeedstudio.com/wiki/index.php?title=Twig_-_OLED_96x96
|
||||
*/
|
||||
static const uint8_t u8g_dev_ssd1327_2bit_96x96_init_seq[] PROGMEM = {
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0fd, 0x012, /* unlock display, usually not required because the display is unlocked after reset */
|
||||
0x0ae, /* display off, sleep mode */
|
||||
0x0a8, 0x05f, /* multiplex ratio: 0x05f * 1/64 duty */
|
||||
0x0a1, 0x000, /* display start line */
|
||||
0x0a2, 0x060, /* display offset, shift mapping ram counter */
|
||||
//0x0a2, 0x04c, /* NHD: display offset, shift mapping ram counter */
|
||||
0x0a0, 0x046, /* remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
|
||||
//0x0a0, 0x056, /* NHD: remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
|
||||
0x0ab, 0x001, /* Enable internal VDD regulator (RESET) */
|
||||
0x081, 0x053, /* contrast, brightness, 0..128, Newhaven: 0x040, LY120 0x053, 0x070 seems also ok */
|
||||
0x0b1, 0x051, /* phase length */
|
||||
0x0b3, 0x001, /* set display clock divide ratio/oscillator frequency */
|
||||
0x0b9, /* use linear lookup table */
|
||||
#if 0
|
||||
0x0b8, /* set gray scale table */
|
||||
//0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
|
||||
0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x077, 0x077, // 4L mode uses 0, 2, 4, 7
|
||||
#endif
|
||||
0x0bc, 0x008, /* pre-charge voltage level */
|
||||
0x0be, 0x007, /* VCOMH voltage */
|
||||
0x0b6, 0x001, /* second precharge */
|
||||
0x0d5, 0x062, /* enable second precharge, internal vsl (bit0 = 0) */
|
||||
|
||||
#if 0
|
||||
// the following commands are not used by the SeeedGrayOLED sequence */
|
||||
0x0ad, 0x002, /* master configuration: disable embedded DC-DC, enable internal VCOMH */
|
||||
0x086, /* full current range (0x084, 0x085, 0x086) */
|
||||
0x0b2, 0x051, /* frame frequency (row period) */
|
||||
0x0b4, 0x002, /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0b0, 0x028, /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
0x0bf, 0x002|0x00d, /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
|
||||
#endif
|
||||
|
||||
0x0a5, /* all pixel on */
|
||||
//0x02e, /* no scroll (according to SeeedGrayOLED sequence) */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display mode */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* all pixel on */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display mode */
|
||||
|
||||
0x015, /* column address... */
|
||||
0x008, /* start at column 8, special for the LY120 ??? */
|
||||
0x037, /* end at column 55, note: there are two pixel in one column */
|
||||
|
||||
0x075, /* row address... */
|
||||
0x008,
|
||||
0x05f,
|
||||
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
|
||||
0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
|
||||
0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
|
||||
0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1327_2bit_96x96_prepare_page_seq[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x015, /* column address... */
|
||||
XOFFSET, /* start at column 8, special for the LY120 ??? */
|
||||
0x037, /* end at column 55, note: there are two pixel in one column */
|
||||
0x075, /* row address... */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static void u8g_dev_ssd1327_2bit_prepare_page(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_prepare_page_seq);
|
||||
|
||||
page <<= 2;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1327_2bit_2x_prepare_page(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_prepare_page_seq);
|
||||
|
||||
page <<= 1;
|
||||
page += is_odd;
|
||||
|
||||
page <<= 2;
|
||||
u8g_WriteByte(u8g, dev, page); /* start at the selected page */
|
||||
page += 3;
|
||||
u8g_WriteByte(u8g, dev, page); /* end within the selected page */
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
}
|
||||
|
||||
/* assumes row autoincrement and activated nibble remap */
|
||||
static void u8g_dev_ssd1327_2bit_write_4_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
|
||||
{
|
||||
uint8_t d, tmp, cnt;
|
||||
static uint8_t buf[4];
|
||||
buf[0] = 0;
|
||||
buf[1] = 0;
|
||||
buf[2] = 0;
|
||||
buf[3] = 0;
|
||||
cnt = 0;
|
||||
do
|
||||
{
|
||||
if ( left == 0 && right == 0 )
|
||||
break;
|
||||
d = left;
|
||||
d &= 3;
|
||||
d <<= 4;
|
||||
tmp = right;
|
||||
tmp &= 3;
|
||||
d |= tmp;
|
||||
d <<= 2;
|
||||
buf[cnt] = d;
|
||||
left >>= 2;
|
||||
right >>= 2;
|
||||
cnt++;
|
||||
}while ( cnt < 4 );
|
||||
u8g_WriteSequence(u8g, dev, 4, buf);
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1327_2bit_write_buffer(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t cnt, left, right;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
cnt = pb->width;
|
||||
cnt >>= 1;
|
||||
ptr = pb->buf;
|
||||
do
|
||||
{
|
||||
left = *ptr++;
|
||||
right = *ptr++;
|
||||
u8g_dev_ssd1327_2bit_write_4_pixel(u8g, dev, left, right);
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
}
|
||||
|
||||
static void u8g_dev_ssd1327_2bit_2x_write_buffer(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
|
||||
{
|
||||
uint8_t cnt, left, right;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
ptr = pb->buf;
|
||||
cnt = pb->width;
|
||||
if ( is_odd )
|
||||
ptr += cnt;
|
||||
cnt >>= 1;
|
||||
do
|
||||
{
|
||||
left = *ptr++;
|
||||
right = *ptr++;
|
||||
u8g_dev_ssd1327_2bit_write_4_pixel(u8g, dev, left, right);
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1327_96x96_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1327_2bit_prepare_page(u8g, dev);
|
||||
u8g_dev_ssd1327_2bit_write_buffer(u8g, dev);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1327_96x96_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_dev_ssd1327_2bit_2x_prepare_page(u8g, dev, 0);
|
||||
u8g_dev_ssd1327_2bit_2x_write_buffer(u8g, dev, 0);
|
||||
u8g_dev_ssd1327_2bit_2x_prepare_page(u8g, dev, 1);
|
||||
u8g_dev_ssd1327_2bit_2x_write_buffer(u8g, dev, 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1327_96x96_gr_sw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1327_96x96_gr_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1327_96x96_gr_hw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1327_96x96_gr_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1327_96x96_gr_i2c , WIDTH, HEIGHT, 4, u8g_dev_ssd1327_96x96_gr_fn, U8G_COM_SSD_I2C);
|
||||
|
||||
#define DWIDTH (2*WIDTH)
|
||||
uint8_t u8g_dev_ssd1327_96x96_2x_buf[DWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_ssd1327_96x96_2x_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1327_96x96_2x_buf};
|
||||
u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_sw_spi = { u8g_dev_ssd1327_96x96_2x_gr_fn, &u8g_dev_ssd1327_96x96_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_hw_spi = { u8g_dev_ssd1327_96x96_2x_gr_fn, &u8g_dev_ssd1327_96x96_2x_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_i2c = { u8g_dev_ssd1327_96x96_2x_gr_fn, &u8g_dev_ssd1327_96x96_2x_pb, U8G_COM_SSD_I2C };
|
||||
|
@ -1,787 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_ssd1351_128x128.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, jamjardavies@gmail.com
|
||||
Copyright (c) 2013, 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.
|
||||
|
||||
History:
|
||||
Initial version 20 May 2013 jamjardavies@gmail.com
|
||||
indexed device 22 May 2013 olikraus@gmail.com
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_ssd1351_128x128_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_DLY(50),
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50),
|
||||
|
||||
0xfd, /* Command Lock */
|
||||
U8G_ESC_ADR(1),
|
||||
0x12,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xfd,
|
||||
U8G_ESC_ADR(1),
|
||||
0xb1, /* Command Lock */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xae, /* Set Display Off */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb3,
|
||||
U8G_ESC_ADR(1),
|
||||
0xf1, /* Front Clock Div */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xca,
|
||||
U8G_ESC_ADR(1),
|
||||
0x7f, /* Set Multiplex Ratio */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xa0,
|
||||
U8G_ESC_ADR(1),
|
||||
0xb4, /* Set Colour Depth */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x15,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, 0x7f, /* Set Column Address */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x75,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, 0x7f, /* Set Row Address */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xa1,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, /* Set Display Start Line */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xa2,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, /* Set Display Offset */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb5,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, /* Set GPIO */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xab,
|
||||
U8G_ESC_ADR(1),
|
||||
0x01, /* Set Function Selection */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb1,
|
||||
U8G_ESC_ADR(1),
|
||||
0x32, /* Set Phase Length */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb4,
|
||||
U8G_ESC_ADR(1),
|
||||
0xa0, 0xb5, 0x55, /* Set Segment Low Voltage */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xbb,
|
||||
U8G_ESC_ADR(1),
|
||||
0x17, /* Set Precharge Voltage */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xbe,
|
||||
U8G_ESC_ADR(1),
|
||||
0x05, /* Set VComH Voltage */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xc1,
|
||||
U8G_ESC_ADR(1),
|
||||
0xc8, 0x80, 0xc8, /* Set Contrast */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xc7,
|
||||
U8G_ESC_ADR(1),
|
||||
0x0f, /* Set Master Contrast */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb6,
|
||||
U8G_ESC_ADR(1),
|
||||
0x01, /* Set Second Precharge Period */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xa6, /* Set Display Mode Reset */
|
||||
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb8, /* Set CMD Grayscale Lookup */
|
||||
U8G_ESC_ADR(1),
|
||||
0x05,
|
||||
0x06,
|
||||
0x07,
|
||||
0x08,
|
||||
0x09,
|
||||
0x0a,
|
||||
0x0b,
|
||||
0x0c,
|
||||
0x0D,
|
||||
0x0E,
|
||||
0x0F,
|
||||
0x10,
|
||||
0x11,
|
||||
0x12,
|
||||
0x13,
|
||||
0x14,
|
||||
0x15,
|
||||
0x16,
|
||||
0x18,
|
||||
0x1a,
|
||||
0x1b,
|
||||
0x1C,
|
||||
0x1D,
|
||||
0x1F,
|
||||
0x21,
|
||||
0x23,
|
||||
0x25,
|
||||
0x27,
|
||||
0x2A,
|
||||
0x2D,
|
||||
0x30,
|
||||
0x33,
|
||||
0x36,
|
||||
0x39,
|
||||
0x3C,
|
||||
0x3F,
|
||||
0x42,
|
||||
0x45,
|
||||
0x48,
|
||||
0x4C,
|
||||
0x50,
|
||||
0x54,
|
||||
0x58,
|
||||
0x5C,
|
||||
0x60,
|
||||
0x64,
|
||||
0x68,
|
||||
0x6C,
|
||||
0x70,
|
||||
0x74,
|
||||
0x78,
|
||||
0x7D,
|
||||
0x82,
|
||||
0x87,
|
||||
0x8C,
|
||||
0x91,
|
||||
0x96,
|
||||
0x9B,
|
||||
0xA0,
|
||||
0xA5,
|
||||
0xAA,
|
||||
0xAF,
|
||||
0xB4,
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xaf, /* Set Display On */
|
||||
0x5c,
|
||||
U8G_ESC_DLY(50),
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1),
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
/* set gpio to high */
|
||||
static const uint8_t u8g_dev_ssd1351_128x128gh_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_DLY(50),
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50),
|
||||
|
||||
0xfd, /* Command Lock */
|
||||
U8G_ESC_ADR(1),
|
||||
0x12,
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xfd,
|
||||
U8G_ESC_ADR(1),
|
||||
0xb1, /* Command Lock */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xae, /* Set Display Off */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb3,
|
||||
U8G_ESC_ADR(1),
|
||||
0xf1, /* Front Clock Div */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xca,
|
||||
U8G_ESC_ADR(1),
|
||||
0x7f, /* Set Multiplex Ratio */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xa0,
|
||||
U8G_ESC_ADR(1),
|
||||
0xb4, /* Set Colour Depth */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x15,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, 0x7f, /* Set Column Address */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x75,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, 0x7f, /* Set Row Address */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xa1,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, /* Set Display Start Line */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xa2,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, /* Set Display Offset */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb5,
|
||||
U8G_ESC_ADR(1),
|
||||
0x03, /* Set GPIO to High Level */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xab,
|
||||
U8G_ESC_ADR(1),
|
||||
0x01, /* Set Function Selection */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb1,
|
||||
U8G_ESC_ADR(1),
|
||||
0x32, /* Set Phase Length */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb4,
|
||||
U8G_ESC_ADR(1),
|
||||
0xa0, 0xb5, 0x55, /* Set Segment Low Voltage */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xbb,
|
||||
U8G_ESC_ADR(1),
|
||||
0x17, /* Set Precharge Voltage */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xbe,
|
||||
U8G_ESC_ADR(1),
|
||||
0x05, /* Set VComH Voltage */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xc1,
|
||||
U8G_ESC_ADR(1),
|
||||
0xc8, 0x80, 0xc8, /* Set Contrast */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xc7,
|
||||
U8G_ESC_ADR(1),
|
||||
0x0f, /* Set Master Contrast */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb6,
|
||||
U8G_ESC_ADR(1),
|
||||
0x01, /* Set Second Precharge Period */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xa6, /* Set Display Mode Reset */
|
||||
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xb8, /* Set CMD Grayscale Lookup */
|
||||
U8G_ESC_ADR(1),
|
||||
0x05,
|
||||
0x06,
|
||||
0x07,
|
||||
0x08,
|
||||
0x09,
|
||||
0x0a,
|
||||
0x0b,
|
||||
0x0c,
|
||||
0x0D,
|
||||
0x0E,
|
||||
0x0F,
|
||||
0x10,
|
||||
0x11,
|
||||
0x12,
|
||||
0x13,
|
||||
0x14,
|
||||
0x15,
|
||||
0x16,
|
||||
0x18,
|
||||
0x1a,
|
||||
0x1b,
|
||||
0x1C,
|
||||
0x1D,
|
||||
0x1F,
|
||||
0x21,
|
||||
0x23,
|
||||
0x25,
|
||||
0x27,
|
||||
0x2A,
|
||||
0x2D,
|
||||
0x30,
|
||||
0x33,
|
||||
0x36,
|
||||
0x39,
|
||||
0x3C,
|
||||
0x3F,
|
||||
0x42,
|
||||
0x45,
|
||||
0x48,
|
||||
0x4C,
|
||||
0x50,
|
||||
0x54,
|
||||
0x58,
|
||||
0x5C,
|
||||
0x60,
|
||||
0x64,
|
||||
0x68,
|
||||
0x6C,
|
||||
0x70,
|
||||
0x74,
|
||||
0x78,
|
||||
0x7D,
|
||||
0x82,
|
||||
0x87,
|
||||
0x8C,
|
||||
0x91,
|
||||
0x96,
|
||||
0x9B,
|
||||
0xA0,
|
||||
0xA5,
|
||||
0xAA,
|
||||
0xAF,
|
||||
0xB4,
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xaf, /* Set Display On */
|
||||
0x5c,
|
||||
U8G_ESC_DLY(50),
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1),
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
#define u8g_dev_ssd1351_128x128_init_seq u8g_dev_ssd1351_128x128_init_seq
|
||||
|
||||
static const uint8_t u8g_dev_ssd1351_128x128_column_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(1),
|
||||
U8G_ESC_ADR(0), 0x15,
|
||||
U8G_ESC_ADR(1), 0x00, 0x7f,
|
||||
U8G_ESC_ADR(0), 0x75,
|
||||
U8G_ESC_ADR(1), 0x00, 0x7f,
|
||||
U8G_ESC_ADR(0), 0x5c,
|
||||
U8G_ESC_ADR(1),
|
||||
U8G_ESC_CS(0),
|
||||
U8G_ESC_END
|
||||
};
|
||||
|
||||
#define RGB332_STREAM_BYTES 8
|
||||
static uint8_t u8g_ssd1351_stream_bytes[RGB332_STREAM_BYTES*3];
|
||||
|
||||
void u8g_ssd1351_to_stream(uint8_t *ptr)
|
||||
{
|
||||
uint8_t cnt = RGB332_STREAM_BYTES;
|
||||
uint8_t val;
|
||||
uint8_t *dest = u8g_ssd1351_stream_bytes;
|
||||
for( cnt = 0; cnt < RGB332_STREAM_BYTES; cnt++ )
|
||||
{
|
||||
val = *ptr++;
|
||||
*dest++ = ((val & 0xe0) >> 2);
|
||||
*dest++ = ((val & 0x1c) << 1);
|
||||
*dest++ = ((val & 0x03) << 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef OBSOLETE
|
||||
// Convert the internal RGB 332 to R
|
||||
static uint8_t u8g_ssd1351_get_r(uint8_t colour)
|
||||
{
|
||||
//return ((colour & 0xe0) >> 5) * 9;
|
||||
//return ((colour & 0xe0) >> 5) * 8;
|
||||
return ((colour & 0xe0) >> 2) ;
|
||||
}
|
||||
|
||||
// Convert the internal RGB 332 to G
|
||||
static uint8_t u8g_ssd1351_get_g(uint8_t colour)
|
||||
{
|
||||
//return ((colour & 0x1c) >> 2) * 9;
|
||||
//return ((colour & 0x1c) >> 2) * 8;
|
||||
return ((colour & 0x1c) << 1);
|
||||
}
|
||||
|
||||
// Convert the internal RGB 332 to B
|
||||
static uint8_t u8g_ssd1351_get_b(uint8_t colour)
|
||||
{
|
||||
//return (colour & 0x03) * 21;
|
||||
return (colour & 0x03) * 16;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1351_128x128_332_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
// u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_init_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_column_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_uint_t x;
|
||||
uint8_t page_height;
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *ptr = pb->buf;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
|
||||
page_height = pb->p.page_y1;
|
||||
page_height -= pb->p.page_y0;
|
||||
page_height++;
|
||||
for( i = 0; i < page_height; i++ )
|
||||
{
|
||||
|
||||
for (x = 0; x < pb->width; x+=RGB332_STREAM_BYTES)
|
||||
{
|
||||
u8g_ssd1351_to_stream(ptr);
|
||||
u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1351_stream_bytes);
|
||||
ptr += RGB332_STREAM_BYTES;
|
||||
}
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_R3G3B2;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1351_128x128gh_332_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
// u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128gh_init_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_column_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_uint_t x;
|
||||
uint8_t page_height;
|
||||
uint8_t i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *ptr = pb->buf;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
|
||||
page_height = pb->p.page_y1;
|
||||
page_height -= pb->p.page_y0;
|
||||
page_height++;
|
||||
for( i = 0; i < page_height; i++ )
|
||||
{
|
||||
|
||||
for (x = 0; x < pb->width; x+=RGB332_STREAM_BYTES)
|
||||
{
|
||||
u8g_ssd1351_to_stream(ptr);
|
||||
u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1351_stream_bytes);
|
||||
ptr += RGB332_STREAM_BYTES;
|
||||
}
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_R3G3B2;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
static uint8_t u8g_dev_ssd1351_128x128_r[256];
|
||||
static uint8_t u8g_dev_ssd1351_128x128_g[256];
|
||||
static uint8_t u8g_dev_ssd1351_128x128_b[256];
|
||||
|
||||
uint8_t u8g_dev_ssd1351_128x128_idx_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
// u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_init_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
u8g_dev_ssd1351_128x128_r[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->r;
|
||||
u8g_dev_ssd1351_128x128_g[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->g;
|
||||
u8g_dev_ssd1351_128x128_b[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->b;
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_column_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
int x;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *ptr = pb->buf;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
|
||||
for (x = 0; x < pb->width; x++)
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ssd1351_128x128_r[(*ptr)>>2]);
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ssd1351_128x128_g[(*ptr)>>2]);
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ssd1351_128x128_b[(*ptr)>>2]);
|
||||
|
||||
ptr++;
|
||||
}
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_INDEX;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
void u8g_ssd1351_hicolor_to_stream(uint8_t *ptr)
|
||||
{
|
||||
register uint8_t cnt = RGB332_STREAM_BYTES;
|
||||
register uint8_t low, high, r, g, b;
|
||||
uint8_t *dest = u8g_ssd1351_stream_bytes;
|
||||
for( cnt = 0; cnt < RGB332_STREAM_BYTES; cnt++ )
|
||||
{
|
||||
low = *ptr++;
|
||||
high = *ptr++;
|
||||
|
||||
r = high & ~7;
|
||||
r >>= 2;
|
||||
b = low & 31;
|
||||
b <<= 1;
|
||||
g = high & 7;
|
||||
g <<= 3;
|
||||
g |= (low>>5)&7;
|
||||
|
||||
*dest++ = r;
|
||||
*dest++ = g;
|
||||
*dest++ = b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1351_128x128_hicolor_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_column_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t i, j;
|
||||
uint8_t page_height;
|
||||
uint8_t *ptr = pb->buf;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
|
||||
page_height = pb->p.page_y1;
|
||||
page_height -= pb->p.page_y0;
|
||||
page_height++;
|
||||
for( j = 0; j < page_height; j++ )
|
||||
{
|
||||
for (i = 0; i < pb->width; i+=RGB332_STREAM_BYTES)
|
||||
{
|
||||
u8g_ssd1351_hicolor_to_stream(ptr);
|
||||
u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1351_stream_bytes);
|
||||
ptr += RGB332_STREAM_BYTES*2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
}
|
||||
break; /* continue to base fn */
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_HICOLOR;
|
||||
}
|
||||
return u8g_dev_pbxh16_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1351_128x128gh_hicolor_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128gh_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1351_128x128_column_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t i, j;
|
||||
uint8_t page_height;
|
||||
uint8_t *ptr = pb->buf;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
|
||||
page_height = pb->p.page_y1;
|
||||
page_height -= pb->p.page_y0;
|
||||
page_height++;
|
||||
for( j = 0; j < page_height; j++ )
|
||||
{
|
||||
for (i = 0; i < pb->width; i+=RGB332_STREAM_BYTES)
|
||||
{
|
||||
u8g_ssd1351_hicolor_to_stream(ptr);
|
||||
u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1351_stream_bytes);
|
||||
ptr += RGB332_STREAM_BYTES*2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
}
|
||||
break; /* continue to base fn */
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_HICOLOR;
|
||||
}
|
||||
return u8g_dev_pbxh16_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1351_128x128_byte_buf[WIDTH*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
|
||||
u8g_pb_t u8g_dev_ssd1351_128x128_byte_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1351_128x128_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128_332_sw_spi = { u8g_dev_ssd1351_128x128_332_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128_332_hw_spi = { u8g_dev_ssd1351_128x128_332_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128gh_332_sw_spi = { u8g_dev_ssd1351_128x128gh_332_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128gh_332_hw_spi = { u8g_dev_ssd1351_128x128gh_332_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
//u8g_dev_t u8g_dev_ssd1351_128x128_idx_sw_spi = { u8g_dev_ssd1351_128x128_idx_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_SW_SPI };
|
||||
//u8g_dev_t u8g_dev_ssd1351_128x128_idx_hw_spi = { u8g_dev_ssd1351_128x128_idx_fn, &u8g_dev_ssd1351_128x128_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
|
||||
/* only half of the height, because two bytes are needed for one pixel */
|
||||
u8g_pb_t u8g_dev_ssd1351_128x128_hicolor_byte_pb = { {PAGE_HEIGHT/2, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1351_128x128_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128_hicolor_sw_spi = { u8g_dev_ssd1351_128x128_hicolor_fn, &u8g_dev_ssd1351_128x128_hicolor_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128_hicolor_hw_spi = { u8g_dev_ssd1351_128x128_hicolor_fn, &u8g_dev_ssd1351_128x128_hicolor_byte_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128gh_hicolor_sw_spi = { u8g_dev_ssd1351_128x128gh_hicolor_fn, &u8g_dev_ssd1351_128x128_hicolor_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128gh_hicolor_hw_spi = { u8g_dev_ssd1351_128x128gh_hicolor_fn, &u8g_dev_ssd1351_128x128_hicolor_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1351_128x128_4x_byte_buf[WIDTH*PAGE_HEIGHT*4] U8G_NOCOMMON ;
|
||||
|
||||
u8g_pb_t u8g_dev_ssd1351_128x128_4x_332_byte_pb = { {PAGE_HEIGHT*4, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1351_128x128_4x_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128_4x_332_sw_spi = { u8g_dev_ssd1351_128x128_332_fn, &u8g_dev_ssd1351_128x128_4x_332_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128_4x_332_hw_spi = { u8g_dev_ssd1351_128x128_332_fn, &u8g_dev_ssd1351_128x128_4x_332_byte_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_332_sw_spi = { u8g_dev_ssd1351_128x128gh_332_fn, &u8g_dev_ssd1351_128x128_4x_332_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_332_hw_spi = { u8g_dev_ssd1351_128x128gh_332_fn, &u8g_dev_ssd1351_128x128_4x_332_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
u8g_pb_t u8g_dev_ssd1351_128x128_4x_hicolor_byte_pb = { {PAGE_HEIGHT/2*4, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1351_128x128_4x_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128_4x_hicolor_sw_spi = { u8g_dev_ssd1351_128x128_hicolor_fn, &u8g_dev_ssd1351_128x128_4x_hicolor_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128_4x_hicolor_hw_spi = { u8g_dev_ssd1351_128x128_hicolor_fn, &u8g_dev_ssd1351_128x128_4x_hicolor_byte_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_hicolor_sw_spi = { u8g_dev_ssd1351_128x128gh_hicolor_fn, &u8g_dev_ssd1351_128x128_4x_hicolor_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1351_128x128gh_4x_hicolor_hw_spi = { u8g_dev_ssd1351_128x128gh_hicolor_fn, &u8g_dev_ssd1351_128x128_4x_hicolor_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
|
||||
/*
|
||||
U8G_PB_DEV(u8g_dev_ssd1351_128x128_332_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1351_128x128_332_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1351_128x128_332_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1351_128x128_332_fn, U8G_COM_HW_SPI);
|
||||
|
||||
U8G_PB_DEV(u8g_dev_ssd1351_128x128_idx_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1351_128x128_idx_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_ssd1351_128x128_idx_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1351_128x128_idx_fn, U8G_COM_HW_SPI);
|
||||
*/
|
||||
|
@ -1,425 +0,0 @@
|
||||
/*
|
||||
u8g_dev_ssd1353_160x128.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2015, hugodan3@googlemail.com
|
||||
Copyright (c) 2013, jamjardavies@gmail.com
|
||||
Copyright (c) 2013, 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.
|
||||
|
||||
History:
|
||||
Initial version 8 Mar 2015 hugodan3@googlemail.com. This version has
|
||||
been derived from the ssd1351 driver by jamjarda. It has
|
||||
been improved by in-lining time critical functions.
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 160
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
#define USE_GREY_TABLE 0
|
||||
|
||||
static const uint8_t u8g_dev_ssd1353_160x128_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_DLY(50),
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_DLY(50),
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0xFD, /* Command unlock */
|
||||
U8G_ESC_ADR(1),
|
||||
0x12,
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xAE, /* Set Display Off */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xA8,
|
||||
U8G_ESC_ADR(1),
|
||||
0x7F, /* Set Multiplex Ratio */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xA0,
|
||||
U8G_ESC_ADR(1),
|
||||
0xB4, /* Set remapping */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xA1,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, /* Set Display Start Line */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xA2,
|
||||
U8G_ESC_ADR(1),
|
||||
0x00, /* Set Display Offset */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xB1,
|
||||
U8G_ESC_ADR(1),
|
||||
0x32, /* Set Phase Length */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xB4,
|
||||
U8G_ESC_ADR(1),
|
||||
0x04, /* Set Second Precharge Period */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xA4, /* Set Display Mode ON */
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xB3,
|
||||
U8G_ESC_ADR(1), /* frame rate */
|
||||
0x40,
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xBB,
|
||||
U8G_ESC_ADR(1), /* pre-charge level */
|
||||
0x08,
|
||||
|
||||
U8G_ESC_ADR(0),
|
||||
0xBE,
|
||||
U8G_ESC_ADR(1), /* vcomh */
|
||||
0x3C,
|
||||
|
||||
/* color adjustments */
|
||||
#if USE_GREY_TABLE != 1
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x81,
|
||||
U8G_ESC_ADR(1),
|
||||
0xC8, /* Set Contrast Color 1*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x82,
|
||||
U8G_ESC_ADR(1),
|
||||
0x80, /* Set Contrast Color 2*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x83,
|
||||
U8G_ESC_ADR(1),
|
||||
0xF8, /* Set Contrast Color 3*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x87,
|
||||
U8G_ESC_ADR(1),
|
||||
0x09, /* Set Master Contrast MAX */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xB9, /* Set CMD Grayscale Linear */
|
||||
#else
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x81,
|
||||
U8G_ESC_ADR(1),
|
||||
0xC8, /* Set Contrast Color 1*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x82,
|
||||
U8G_ESC_ADR(1),
|
||||
0xA0, /* Set Contrast Color 2*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x83,
|
||||
U8G_ESC_ADR(1),
|
||||
0xB0, /* Set Contrast Color 3*/
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0x87,
|
||||
U8G_ESC_ADR(1),
|
||||
0x0F, /* Set Master Contrast MAX */
|
||||
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
0xB8, /* Set CMD Grayscale Lookup */
|
||||
U8G_ESC_ADR(1),
|
||||
0x05, 0x06, 0x07, 0x08,
|
||||
0x09, 0x0a, 0x0b, 0x0c,
|
||||
0x0D, 0x0E, 0x0F, 0x10,
|
||||
0x11, 0x12, 0x13, 0x14,
|
||||
0x15, 0x16, 0x18, 0x1a,
|
||||
0x1b, 0x1C, 0x1D, 0x1F,
|
||||
0x21, 0x23, 0x25, 0x27,
|
||||
0x2A, 0x2D, 0x30, 0x33,
|
||||
0x36, 0x39, 0x3C, 0x3F,
|
||||
0x42, 0x45, 0x48, 0x4C,
|
||||
0x50, 0x54, 0x58, 0x5C,
|
||||
0x60, 0x64, 0x68, 0x6C,
|
||||
0x70, 0x74, 0x78, 0x7D,
|
||||
0x82, 0x87, 0x8C, 0x91,
|
||||
0x96, 0x9B, 0xA0, 0xA5,
|
||||
0xAA, 0xAF, 0xB4,
|
||||
#endif
|
||||
U8G_ESC_ADR(0),
|
||||
0xAF, /* Set Display On */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(1),
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_ssd1353_160x128_column_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(1),
|
||||
U8G_ESC_ADR(0), 0x15,
|
||||
U8G_ESC_ADR(1), 0x00, 0x9f,
|
||||
U8G_ESC_ADR(0), 0x75,
|
||||
U8G_ESC_ADR(1), 0x00, 0x7f,
|
||||
U8G_ESC_ADR(0), 0x5c,
|
||||
U8G_ESC_ADR(1),
|
||||
U8G_ESC_CS(0),
|
||||
U8G_ESC_END
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1353_160x128_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_CS(1),
|
||||
U8G_ESC_ADR(0), 0xAE,
|
||||
U8G_ESC_CS(0),
|
||||
U8G_ESC_END
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_ssd1353_160x128_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_CS(1),
|
||||
U8G_ESC_ADR(0), 0xAF,
|
||||
U8G_ESC_CS(0),
|
||||
U8G_ESC_END
|
||||
};
|
||||
|
||||
|
||||
#define RGB332_STREAM_BYTES 8
|
||||
static uint8_t u8g_ssd1353_stream_bytes[RGB332_STREAM_BYTES*3];
|
||||
|
||||
uint8_t u8g_dev_ssd1353_160x128_332_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_init_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_column_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_uint_t x;
|
||||
uint8_t page_height;
|
||||
uint8_t i;
|
||||
uint8_t cnt;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *ptr = pb->buf;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
|
||||
page_height = pb->p.page_y1;
|
||||
page_height -= pb->p.page_y0;
|
||||
page_height++;
|
||||
for( i = 0; i < page_height; i++ )
|
||||
{
|
||||
|
||||
for (x = 0; x < pb->width; x+=RGB332_STREAM_BYTES)
|
||||
{
|
||||
/* inline operation for better perf */
|
||||
uint8_t *dest = u8g_ssd1353_stream_bytes;
|
||||
for( cnt = 0; cnt < RGB332_STREAM_BYTES; cnt++ )
|
||||
{
|
||||
uint8_t val = *ptr++;
|
||||
*dest++ = ((val & 0xe0) >> 2);
|
||||
*dest++ = ((val & 0x1c) << 1);
|
||||
*dest++ = ((val & 0x03) << 4);
|
||||
}
|
||||
u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1353_stream_bytes);
|
||||
}
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_sleep_on);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_sleep_off);
|
||||
break;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
/*
|
||||
* not tested and not released, just taken from ssd1351
|
||||
*/
|
||||
static uint8_t u8g_dev_ssd1353_160x128_r[256];
|
||||
static uint8_t u8g_dev_ssd1353_160x128_g[256];
|
||||
static uint8_t u8g_dev_ssd1353_160x128_b[256];
|
||||
|
||||
uint8_t u8g_dev_ssd1353_160x128_idx_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
// u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_init_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
u8g_dev_ssd1353_160x128_r[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->r;
|
||||
u8g_dev_ssd1353_160x128_g[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->g;
|
||||
u8g_dev_ssd1353_160x128_b[ ((u8g_dev_arg_irgb_t *)arg)->idx ] = ((u8g_dev_arg_irgb_t *)arg)->b;
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_column_seq);
|
||||
break;
|
||||
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
int x;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t *ptr = pb->buf;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
|
||||
for (x = 0; x < pb->width; x++)
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ssd1353_160x128_r[(*ptr)>>2]);
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ssd1353_160x128_g[(*ptr)>>2]);
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_ssd1353_160x128_b[(*ptr)>>2]);
|
||||
|
||||
ptr++;
|
||||
}
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_INDEX;
|
||||
}
|
||||
|
||||
return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_ssd1353_160x128_hicolor_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_50NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_column_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
uint8_t i, j;
|
||||
uint8_t page_height;
|
||||
uint8_t *ptr = pb->buf;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
|
||||
page_height = pb->p.page_y1;
|
||||
page_height -= pb->p.page_y0;
|
||||
page_height++;
|
||||
for( j = 0; j < page_height; j++ )
|
||||
{
|
||||
for (i = 0; i < pb->width; i+=RGB332_STREAM_BYTES)
|
||||
{
|
||||
register uint8_t cnt, low, high, r, g, b;
|
||||
uint8_t *dest = u8g_ssd1353_stream_bytes;
|
||||
for( cnt = 0; cnt < RGB332_STREAM_BYTES; cnt++ )
|
||||
{
|
||||
low = *ptr++;
|
||||
high = *ptr++;
|
||||
|
||||
r = high & ~7;
|
||||
r >>= 2;
|
||||
b = low & 31;
|
||||
b <<= 1;
|
||||
g = high & 7;
|
||||
g <<= 3;
|
||||
g |= (low>>5)&7;
|
||||
|
||||
*dest++ = r;
|
||||
*dest++ = g;
|
||||
*dest++ = b;
|
||||
}
|
||||
u8g_WriteSequence(u8g, dev, RGB332_STREAM_BYTES*3, u8g_ssd1353_stream_bytes);
|
||||
}
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break; /* continue to base fn */
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_sleep_on);
|
||||
break;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1353_160x128_sleep_off);
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pbxh16_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_ssd1353_160x128_byte_buf[WIDTH*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
|
||||
u8g_pb_t u8g_dev_ssd1353_160x128_byte_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1353_160x128_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_332_sw_spi = { u8g_dev_ssd1353_160x128_332_fn, &u8g_dev_ssd1353_160x128_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_332_hw_spi = { u8g_dev_ssd1353_160x128_332_fn, &u8g_dev_ssd1353_160x128_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
//u8g_dev_t u8g_dev_ssd1353_160x128_idx_sw_spi = { u8g_dev_ssd1353_160x128_idx_fn, &u8g_dev_ssd1353_160x128_byte_pb, U8G_COM_SW_SPI };
|
||||
//u8g_dev_t u8g_dev_ssd1353_160x128_idx_hw_spi = { u8g_dev_ssd1353_160x128_idx_fn, &u8g_dev_ssd1353_160x128_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
|
||||
/* only half of the height, because two bytes are needed for one pixel */
|
||||
u8g_pb_t u8g_dev_ssd1353_160x128_hicolor_byte_pb = { {PAGE_HEIGHT/2, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1353_160x128_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_hicolor_sw_spi = { u8g_dev_ssd1353_160x128_hicolor_fn, &u8g_dev_ssd1353_160x128_hicolor_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_hicolor_hw_spi = { u8g_dev_ssd1353_160x128_hicolor_fn, &u8g_dev_ssd1353_160x128_hicolor_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
|
||||
/* the 4x buffer is removed since it does not fit the RAM space of very small MCUs */
|
||||
#if 0
|
||||
uint8_t u8g_dev_ssd1353_160x128_4x_byte_buf[WIDTH*PAGE_HEIGHT*4] U8G_NOCOMMON ;
|
||||
|
||||
u8g_pb_t u8g_dev_ssd1353_160x128_4x_332_byte_pb = { {PAGE_HEIGHT*4, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1353_160x128_4x_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_4x_332_sw_spi = { u8g_dev_ssd1353_160x128_332_fn, &u8g_dev_ssd1353_160x128_4x_332_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_4x_332_hw_spi = { u8g_dev_ssd1353_160x128_332_fn, &u8g_dev_ssd1353_160x128_4x_332_byte_pb, U8G_COM_HW_SPI };
|
||||
|
||||
u8g_pb_t u8g_dev_ssd1353_160x128_4x_hicolor_byte_pb = { {PAGE_HEIGHT/2*4, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_ssd1353_160x128_4x_byte_buf};
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_4x_hicolor_sw_spi = { u8g_dev_ssd1353_160x128_hicolor_fn, &u8g_dev_ssd1353_160x128_4x_hicolor_byte_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_ssd1353_160x128_4x_hicolor_hw_spi = { u8g_dev_ssd1353_160x128_hicolor_fn, &u8g_dev_ssd1353_160x128_4x_hicolor_byte_pb, U8G_COM_HW_SPI };
|
||||
#endif
|
@ -1,203 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_64128n.c (Displaytech)
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7565_64128n_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x0A2, /* 0x0a2: LCD bias 1/9 (according to Displaytech 64128N datasheet) */
|
||||
0x0A0, /* Normal ADC Select (according to Displaytech 64128N datasheet) */
|
||||
|
||||
0x0c8, /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
|
||||
0x040, /* Display start line for Displaytech 64128N */
|
||||
|
||||
0x028 | 0x04, /* power control: turn on voltage converter */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x06, /* power control: turn on voltage regulator */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x07, /* power control: turn on voltage follower */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x010, /* Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N */
|
||||
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
|
||||
0x081, /* set contrast */
|
||||
0x01e, /* Contrast value. Setting for controlling brightness of Displaytech 64128N */
|
||||
|
||||
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_64128n_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0x10 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0x00. Changed for DisplayTech 64128N */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_64128n_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_64128n_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7565_64128n_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7565_64128n_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_64128n_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_64128n_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_64128n_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_64128n_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_64128n_parallel, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_64128n_fn, U8G_COM_PARALLEL);
|
||||
|
||||
uint8_t u8g_dev_st7565_64128n_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_st7565_64128n_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7565_64128n_2x_buf};
|
||||
u8g_dev_t u8g_dev_st7565_64128n_2x_sw_spi = { u8g_dev_st7565_64128n_2x_fn, &u8g_dev_st7565_64128n_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_st7565_64128n_2x_hw_spi = { u8g_dev_st7565_64128n_2x_fn, &u8g_dev_st7565_64128n_2x_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_st7565_64128n_2x_hw_parallel = { u8g_dev_st7565_64128n_2x_fn, &u8g_dev_st7565_64128n_2x_pb, U8G_COM_PARALLEL };
|
@ -1,190 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_dogm128.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
const uint8_t u8g_dev_st7565_dogm128_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x040, /* set display start line */
|
||||
0x0a1, /* ADC set to reverse */
|
||||
0x0c0, /* common output mode: set scan direction normal operation */
|
||||
0x0a6, /* display normal (none reverse) */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x027, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x018, /* contrast value, EA default: 0x016 */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0a4, /* normal display (not all on) */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm128_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm128_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm128_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7565_dogm128_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7565_dogm128_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_dogm128_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm128_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_dogm128_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm128_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_dogm128_parallel, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm128_fn, U8G_COM_PARALLEL);
|
||||
|
||||
|
||||
uint8_t u8g_dev_st7565_dogm128_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_st7565_dogm128_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7565_dogm128_2x_buf};
|
||||
u8g_dev_t u8g_dev_st7565_dogm128_2x_sw_spi = { u8g_dev_st7565_dogm128_2x_fn, &u8g_dev_st7565_dogm128_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_st7565_dogm128_2x_hw_spi = { u8g_dev_st7565_dogm128_2x_fn, &u8g_dev_st7565_dogm128_2x_pb, U8G_COM_HW_SPI };
|
||||
u8g_dev_t u8g_dev_st7565_dogm128_2x_parallel = { u8g_dev_st7565_dogm128_2x_fn, &u8g_dev_st7565_dogm128_2x_pb, U8G_COM_PARALLEL };
|
@ -1,157 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_dogm132.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 132
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm132_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x040, /* set display start line to 0 */
|
||||
0x0a1, /* ADC set to reverse */
|
||||
0x0c0, /* common output mode */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x023, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x01f, /* contrast value, EA default: 0x01f */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
|
||||
#ifdef OBSOLETE_DOGM128
|
||||
0x040, /* set display start line */
|
||||
0x0c8, /* set scan direction inverse operation */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x027, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x018, /* contrast value, EA default: 0x016 */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
#endif
|
||||
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm132_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm132_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_dogm132_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7565_dogm132_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_dogm132_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm132_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_dogm132_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm132_fn, U8G_COM_HW_SPI);
|
@ -1,205 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_lm6059.c (Adafruit display)
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7565_lm6059_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x0a3, /* 0x0a2: LCD bias 1/9 (suggested for the LM6063), 0x0a3: Used by Adafruit, 0x0a2 does not work */
|
||||
/* the LM6059 vs LM6063, ADC and SHL have inverted settings */
|
||||
0x0a0, /* 0x0a1: ADC set to normal (suggested for the LM6059), 0x0a0: Used by Adafruit -> normal mode */
|
||||
0x0c8, /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
|
||||
0x060, /* set display start line */
|
||||
|
||||
0x028 | 0x04, /* power control: turn on voltage converter */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x06, /* power control: turn on voltage regulator */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x07, /* power control: turn on voltage follower */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x026, /* set V0 voltage resistor ratio to 6 (Adafruit Value, no info from LM6063 Manual) */
|
||||
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
|
||||
0x081, /* set contrast */
|
||||
0x018, /* contrast value*/
|
||||
|
||||
/*0x0ac,*/ /* indicator */
|
||||
/*0x000,*/ /* disable */
|
||||
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_lm6059_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x001, /* set lower 4 bit of the col adr */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_lm6059_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_lm6059_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_st7565_lm6059_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7565_lm6059_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_lm6059_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6059_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_lm6059_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6059_fn, U8G_COM_HW_SPI);
|
||||
|
||||
|
||||
uint8_t u8g_dev_st7565_lm6059_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_st7565_lm6059_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7565_lm6059_2x_buf};
|
||||
u8g_dev_t u8g_dev_st7565_lm6059_2x_sw_spi = { u8g_dev_st7565_lm6059_2x_fn, &u8g_dev_st7565_lm6059_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_st7565_lm6059_2x_hw_spi = { u8g_dev_st7565_lm6059_2x_fn, &u8g_dev_st7565_lm6059_2x_pb, U8G_COM_HW_SPI };
|
@ -1,236 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_lm6063.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
#ifdef OLD_ADAFRUIT_CODE
|
||||
static const uint8_t OLD_u8g_dev_st7565_lm6063_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x040, /* set display start line */
|
||||
0x0a1, /* ADC set to reverse */
|
||||
0x0c8, /* common output mode: set scan direction normal operation/SHL Select / 17 Jan: seems to be a bug, must be 0x0c0 */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
/*0x0f8,*/ /* set booster ratio to */
|
||||
/*0x000, */ /* 4x */
|
||||
/*0x027,*/ /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x018, /* contrast value*/
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
#endif
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7565_lm6063_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x0a3, /* 0x0a2: LCD bias 1/9 (suggested for the LM6063), 0x0a3: Used by Adafruit */
|
||||
0x0a1, /* 0x0a1: ADC set to reverse (suggested for the LM6063), 0x0a0: Used by Adafruit -> normal mode */
|
||||
0x0c0, /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
|
||||
0x040, /* set display start line */
|
||||
|
||||
0x028 | 0x04, /* power control: turn on voltage converter */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x06, /* power control: turn on voltage regulator */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x07, /* power control: turn on voltage follower */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x026, /* set V0 voltage resistor ratio to 6 (Adafruit Value, no info from LM6063 Manual) */
|
||||
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
|
||||
0x081, /* set contrast */
|
||||
0x018, /* contrast value*/
|
||||
|
||||
/*0x0ac,*/ /* indicator */
|
||||
/*0x000,*/ /* disable */
|
||||
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_lm6063_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_st7565_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_st7565_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_st7565_lm6063_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6063_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6063_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_st7565_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_st7565_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7565_lm6063_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6063_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6063_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6063_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_st7565_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_st7565_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_lm6063_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6063_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_lm6063_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6063_fn, U8G_COM_HW_SPI);
|
||||
|
||||
uint8_t u8g_dev_st7565_lm6063_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_st7565_lm6063_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7565_lm6063_2x_buf};
|
||||
u8g_dev_t u8g_dev_st7565_lm6063_2x_sw_spi = { u8g_dev_st7565_lm6063_2x_fn, &u8g_dev_st7565_lm6063_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_st7565_lm6063_2x_hw_spi = { u8g_dev_st7565_lm6063_2x_fn, &u8g_dev_st7565_lm6063_2x_pb, U8G_COM_HW_SPI };
|
||||
|
@ -1,145 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_nhd_c12832.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12832_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x040, /* set display start line to 0 */
|
||||
0x0a0, /* ADC set, values: a0=normal, a1=reverse */
|
||||
0x0c8, /* common output mode: c0=normal, c8=reverse */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x023, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x00a, /* contrast value */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12832_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12832_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12832_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7565_c12832_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_c12832_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_c12832_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_parallel, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_c12832_fn, U8G_COM_PARALLEL);
|
||||
U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_hw_usart_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_c12832_fn, U8G_COM_HW_USART_SPI);
|
||||
|
@ -1,194 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7565_nhd_c12864.c
|
||||
|
||||
Support for the NHD-C12864A1Z-FSB-FBW (Newhaven Display)
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
const uint8_t u8g_dev_st7565_nhd_c12864_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(10), /* do reset low pulse with (10*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x040, /* set display start line */
|
||||
0x0a1, /* ADC set to reverse */
|
||||
0x0c0, /* common output mode: set scan direction normal operation */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x027, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x008, /* contrast: 0x008 is a good value for NHD C12864, Nov 2012: User reports that 0x1a is much better */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_nhd_c12864_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x004, /* set lower 4 bit of the col adr to 4 (NHD C12864) */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12864_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_st7565_c12864_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(0), /* disable chip, bugfix 12 nov 2014 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7565_nhd_c12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7565_nhd_c12864_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7565_nhd_c12864_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_nhd_c12864_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7565_nhd_c12864_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_nhd_c12864_fn, U8G_COM_HW_SPI);
|
||||
|
||||
|
||||
uint8_t u8g_dev_st7565_nhd_c12864_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_st7565_nhd_c12864_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7565_nhd_c12864_2x_buf};
|
||||
u8g_dev_t u8g_dev_st7565_nhd_c12864_2x_sw_spi = { u8g_dev_st7565_nhd_c12864_2x_fn, &u8g_dev_st7565_nhd_c12864_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_st7565_nhd_c12864_2x_hw_spi = { u8g_dev_st7565_nhd_c12864_2x_fn, &u8g_dev_st7565_nhd_c12864_2x_pb, U8G_COM_HW_SPI };
|
||||
|
@ -1,420 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7687_c144mvgd.c (1.44" TFT)
|
||||
|
||||
Status: Started, but not finished
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
#ifdef FIRST_VERSION
|
||||
/*
|
||||
see also: read.pudn.com/downloads115/sourcecode/app/484503/LCM_Display.c__.htm
|
||||
http://en.pudn.com/downloads115/sourcecode/app/detail484503_en.html
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_st7687_c144mvgd_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x001, /* A0=0, SW reset */
|
||||
U8G_ESC_DLY(200), /* delay 200 ms */
|
||||
|
||||
0x0d7, /* EEPROM data auto re-load control */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x09f, /* ARD = 1 */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
0x0e0, /* EEPROM control in */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
#ifdef NOT_REQUIRED
|
||||
0x0fa, /* EEPROM function selection 8.1.66 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
#endif
|
||||
|
||||
0x0e3, /* Read from EEPROM, 8.1.55 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
0x0e1, /* EEPROM control out, 8.1.53 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
//0x028, /* display off */
|
||||
0x011, /* Sleep out & booster on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
0x0c0, /* Vop setting, 8.1.42 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* */
|
||||
0x001, /* 3.6 + 256*0.04 = 13.84 Volt */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
0x0c3, /* Bias selection, 8.1.45 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x003,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c4, /* Booster setting 8.1.46 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x007,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c5, /* ??? */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0cb, /* FV3 with Booster x2 control, 8.1.47 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x036, /* Memory data access control, 8.1.28 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x080,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0b5, /* N-line control, 8.1.37 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x089,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
|
||||
0x0d0, /* Analog circuit setting, 8.1.49 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x01d,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0b7, /* Com/Seg Scan Direction, 8.1.38 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x040,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x025, /* Write contrast, 8.1.17 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x03f,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x03a, /* Interface pixel format, 8.1.32 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x004, /* 3: 12 bit per pixel Type A, 4: 12 bit Type B, 5: 16bit per pixel */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0b0, /* Display Duty setting, 8.1.34 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x07f,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0f0, /* Frame Freq. in Temp range A,B,C and D, 8.1.59 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x007,
|
||||
0x00c,
|
||||
0x00c,
|
||||
0x015,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0f9, /* Frame RGB Value, 8.1.65 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000,
|
||||
0x005,
|
||||
0x008,
|
||||
0x00a,
|
||||
0x00c,
|
||||
0x00e,
|
||||
0x010,
|
||||
0x011,
|
||||
0x012,
|
||||
0x013,
|
||||
0x014,
|
||||
0x015,
|
||||
0x016,
|
||||
0x018,
|
||||
0x01a,
|
||||
0x01b,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0f9, /* Frame RGB Value, 8.1.65 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000,
|
||||
0x000,
|
||||
0x000,
|
||||
0x000,
|
||||
0x033,
|
||||
0x055,
|
||||
0x055,
|
||||
0x055,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x029, /* display on */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
http://www.waitingforfriday.com/images/e/e3/FTM144D01N_test.zip
|
||||
*/
|
||||
|
||||
static const uint8_t u8g_dev_st7687_c144mvgd_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x011, /* Sleep out & booster on */
|
||||
U8G_ESC_DLY(5), /* delay 5 ms */
|
||||
|
||||
0x03a, /* Interface pixel format, 8.1.32 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x004, /* 3: 12 bit per pixel Type A, 4: 12 bit Type B, 5: 16bit per pixel */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
|
||||
0x026, /* SET_GAMMA_CURVE */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x004,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0f2, /* GAM_R_SEL */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x001, /* enable gamma adj */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
|
||||
0x0e0, /* POSITIVE_GAMMA_CORRECT */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x3f,
|
||||
0x25,
|
||||
0x1c,
|
||||
0x1e,
|
||||
0x20,
|
||||
0x12,
|
||||
0x2a,
|
||||
0x90,
|
||||
0x24,
|
||||
0x11,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0e1, /* NEGATIVE_GAMMA_CORRECT */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x20,
|
||||
0x20,
|
||||
0x20,
|
||||
0x20,
|
||||
0x05,
|
||||
0x00,
|
||||
0x15,
|
||||
0xa7,
|
||||
0x3d,
|
||||
0x18,
|
||||
0x25,
|
||||
0x2a,
|
||||
0x2b,
|
||||
0x2b,
|
||||
0x3a,
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0b1, /* FRAME_RATE_CONTROL1 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x008, /* DIVA = 8 */
|
||||
0x008, /* VPA = 8 */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
|
||||
0x0b4, /* DISPLAY_INVERSION */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x007, /* NLA = 1, NLB = 1, NLC = 1 (all on Frame Inversion) */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c0, /* POWER_CONTROL1 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x00a, /* VRH = 10: GVDD = 4.30 */
|
||||
0x002, /* VC = 2: VCI1 = 2.65 */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c1, /* POWER_CONTROL2 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x002, /* BT = 2: AVDD = 2xVCI1, VCL = -1xVCI1, VGH = 5xVCI1, VGL = -2xVCI1 */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c5, /* VCOM_CONTROL1 */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x050, /* VMH = 80: VCOMH voltage = 4.5 */
|
||||
0x05b, /* VML = 91: VCOML voltage = -0.225 */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x0c7, /* VCOM_OFFSET_CONTROL */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x040, /* nVM = 0, VMF = 64: VCOMH output = VMH, VCOML output = VML */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x02a, /* SET_COLUMN_ADDRESS */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* */
|
||||
0x000, /* */
|
||||
0x000, /* */
|
||||
0x07f, /* */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x02b, /* SET_PAGE_ADDRESS */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* */
|
||||
0x000, /* */
|
||||
0x000, /* */
|
||||
0x07f, /* */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
0x036, /* SET_ADDRESS_MODE */
|
||||
U8G_ESC_ADR(1), /* data mode */
|
||||
0x000, /* Select display orientation */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
|
||||
|
||||
0x029, /* display on */
|
||||
|
||||
0x02c, /* write start */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* calculate bytes for Type B 4096 color display */
|
||||
static uint8_t get_byte_1(uint8_t v)
|
||||
{
|
||||
v >>= 4;
|
||||
v &= 0x0e;
|
||||
return v;
|
||||
}
|
||||
|
||||
static uint8_t get_byte_2(uint8_t v)
|
||||
{
|
||||
uint8_t w;
|
||||
w = v;
|
||||
w &= 3;
|
||||
w = (w<<2) | w;
|
||||
v <<= 3;
|
||||
v &= 0x0e0;
|
||||
w |= v;
|
||||
return w;
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7687_c144mvgd_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7687_c144mvgd_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i, j;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x02a ); /* Column address set 8.1.20 */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, 0x000 ); /* x0 */
|
||||
u8g_WriteByte(u8g, dev, WIDTH-1 ); /* x1 */
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x02b ); /* Row address set 8.1.21 */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, y ); /* y0 */
|
||||
u8g_WriteByte(u8g, dev, y+PAGE_HEIGHT-1 ); /* y1 */
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x02c ); /* Memory write 8.1.22 */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
|
||||
for( i = 0; i < PAGE_HEIGHT; i ++ )
|
||||
{
|
||||
|
||||
for( j = 0; j < WIDTH; j ++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, get_byte_1(*ptr) );
|
||||
u8g_WriteByte(u8g, dev, get_byte_2(*ptr) );
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_st7687_c144mvgd_8h8_buf[WIDTH*8] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_st7687_c144mvgd_8h8_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_st7687_c144mvgd_8h8_buf};
|
||||
|
||||
u8g_dev_t u8g_dev_st7687_c144mvgd_sw_spi = { u8g_dev_st7687_c144mvgd_fn, &u8g_st7687_c144mvgd_8h8_pb, u8g_com_arduino_sw_spi_fn };
|
||||
|
||||
u8g_dev_t u8g_dev_st7687_c144mvgd_8bit = { u8g_dev_st7687_c144mvgd_fn, &u8g_st7687_c144mvgd_8h8_pb, U8G_COM_PARALLEL };
|
@ -1,175 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7920_128x64.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7920_128x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_DLY(100), /* 8 Dez 2012: additional delay 100 ms because of reset*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
|
||||
0x00c, /* display on, cursor & blink off; 0x08: all off */
|
||||
0x006, /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
|
||||
0x002, /* disable scroll, enable CGRAM adress */
|
||||
0x001, /* clear RAM, needs 1.6 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
|
||||
if ( y < 32 )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, 0x080 | (y-32) ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | 8); /* set x pos to 64*/
|
||||
}
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7920_128x64_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 32; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
|
||||
if ( y < 32 )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, 0x080 | (y-32) ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | 8); /* set x pos to 64*/
|
||||
}
|
||||
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7920_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_ST7920_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_ST7920_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_128x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_FAST_PARALLEL);
|
||||
U8G_PB_DEV(u8g_dev_st7920_128x64_custom, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, u8g_com_arduino_st7920_custom_fn);
|
||||
|
||||
|
||||
|
||||
#define QWIDTH (WIDTH*4)
|
||||
uint8_t u8g_dev_st7920_128x64_4x_buf[QWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_st7920_128x64_4x_pb = { {32, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7920_128x64_4x_buf};
|
||||
u8g_dev_t u8g_dev_st7920_128x64_4x_sw_spi = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_ST7920_SW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_128x64_4x_hw_spi = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_ST7920_HW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_128x64_4x_8bit = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_FAST_PARALLEL };
|
||||
u8g_dev_t u8g_dev_st7920_128x64_4x_custom = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, u8g_com_arduino_st7920_custom_fn };
|
||||
|
||||
|
@ -1,151 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7920_192x32.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 192
|
||||
#define HEIGHT 32
|
||||
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7920_192x32_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_DLY(100), /* 8 Dez 2012: additional delay 100 ms because of reset*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
|
||||
0x00c, /* display on, cursor & blink off; 0x08: all off */
|
||||
0x006, /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
|
||||
0x002, /* disable scroll, enable CGRAM adress */
|
||||
0x001, /* clear RAM, needs 1.6 ms */
|
||||
U8G_ESC_DLY(100), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7920_192x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_192x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7920_192x32_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_192x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 32; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7920_192x32_sw_spi, WIDTH, HEIGHT, 8, u8g_dev_st7920_192x32_fn, U8G_COM_ST7920_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_192x32_hw_spi, WIDTH, HEIGHT, 8, u8g_dev_st7920_192x32_fn, U8G_COM_ST7920_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_192x32_8bit, WIDTH, HEIGHT, 8, u8g_dev_st7920_192x32_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
|
||||
#define QWIDTH (WIDTH*4)
|
||||
uint8_t u8g_dev_st7920_192x32_4x_buf[QWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_st7920_192x32_4x_pb = { {32, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7920_192x32_4x_buf};
|
||||
u8g_dev_t u8g_dev_st7920_192x32_4x_sw_spi = { u8g_dev_st7920_192x32_4x_fn, &u8g_dev_st7920_192x32_4x_pb, U8G_COM_ST7920_SW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_192x32_4x_hw_spi = { u8g_dev_st7920_192x32_4x_fn, &u8g_dev_st7920_192x32_4x_pb, U8G_COM_ST7920_HW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_192x32_4x_8bit = { u8g_dev_st7920_192x32_4x_fn, &u8g_dev_st7920_192x32_4x_pb, U8G_COM_FAST_PARALLEL };
|
||||
|
@ -1,154 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_st7920_202x32.c
|
||||
tested with CFAG20232
|
||||
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 202
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
|
||||
static const uint8_t u8g_dev_st7920_202x32_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
U8G_ESC_DLY(100), /* 8 Dez 2012: additional delay 100 ms because of reset*/
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x038, /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
|
||||
0x00c, /* display on, cursor & blink off; 0x08: all off */
|
||||
0x006, /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
|
||||
0x002, /* disable scroll, enable CGRAM adress */
|
||||
0x001, /* clear RAM, needs 1.6 ms */
|
||||
U8G_ESC_DLY(100), /* delay 10 ms */
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_st7920_202x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_202x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 8; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_st7920_202x32_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_202x32_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
for( i = 0; i < 32; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x03e ); /* enable extended mode */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | y ); /* y pos */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set x pos to 0*/
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
ptr += WIDTH/8;
|
||||
y++;
|
||||
}
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_st7920_202x32_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_202x32_fn, U8G_COM_ST7920_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_202x32_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_202x32_fn, U8G_COM_ST7920_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_st7920_202x32_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_202x32_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
||||
#define QWIDTH (WIDTH*4)
|
||||
uint8_t u8g_dev_st7920_202x32_4x_buf[QWIDTH] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_st7920_202x32_4x_pb = { {32, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_st7920_202x32_4x_buf};
|
||||
u8g_dev_t u8g_dev_st7920_202x32_4x_sw_spi = { u8g_dev_st7920_202x32_4x_fn, &u8g_dev_st7920_202x32_4x_pb, U8G_COM_ST7920_SW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_202x32_4x_hw_spi = { u8g_dev_st7920_202x32_4x_fn, &u8g_dev_st7920_202x32_4x_pb, U8G_COM_ST7920_HW_SPI };
|
||||
u8g_dev_t u8g_dev_st7920_202x32_4x_8bit = { u8g_dev_st7920_202x32_4x_fn, &u8g_dev_st7920_202x32_4x_pb, U8G_COM_FAST_PARALLEL };
|
||||
|
||||
|
@ -1,193 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_t6963_128x128.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, 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.
|
||||
|
||||
|
||||
Application Notes for the MGLS 128x128
|
||||
www.baso.no/content/pdf/T6963C_Application.pdf
|
||||
|
||||
Hitachi App Notes:
|
||||
https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
|
||||
|
||||
Notes:
|
||||
The font selection pins should generate the 8x8 font.
|
||||
For the MGLS240128TZ only FS1 is available on pin 18.
|
||||
FS1 must be low to generate the 8x8 font.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 16
|
||||
|
||||
|
||||
/*
|
||||
http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
|
||||
*/
|
||||
|
||||
/* text is not used, so settings are not relevant */
|
||||
static const uint8_t u8g_dev_t6963_128x128_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x021, /* set cursor position */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x022, /* set offset */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x040, /* text home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x041, /* text columns */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x042, /* graphics home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x043, /* graphics columns */
|
||||
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x080, /* mode register: OR Mode, Internal Character Mode */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
0x098, /* mode register: Display Mode, Graphics on, Text off, Cursor off */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x024, /* set adr pointer */
|
||||
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_t6963_128x128_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_128x128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < PAGE_HEIGHT; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr&255 ); /* address low byte */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr>>8 ); /* address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x024 ); /* set adr ptr */
|
||||
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
// U8G_PB_DEV(u8g_dev_t6963_128x128_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_128x128_fn, U8G_COM_T6963);
|
||||
|
||||
uint8_t u8g_dev_t6963_128x128_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_t6963_128x128_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_t6963_128x128_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_t6963_128x128_8bit = { u8g_dev_t6963_128x128_fn, &u8g_dev_t6963_128x128_2x_bw_pb, U8G_COM_T6963 };
|
||||
|
||||
|
@ -1,191 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_t6963_128x64.c
|
||||
|
||||
Tested with Varitronix MGLS240128TZ
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, 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.
|
||||
|
||||
|
||||
Application Notes for the MGLS 240x128
|
||||
www.baso.no/content/pdf/T6963C_Application.pdf
|
||||
|
||||
Hitachi App Notes:
|
||||
https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
|
||||
|
||||
Notes:
|
||||
The font selection pins should generate the 8x8 font.
|
||||
For the MGLS240128TZ only FS1 is available on pin 18.
|
||||
FS1 must be low to generate the 8x8 font.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 16
|
||||
|
||||
|
||||
/* text is not used, so settings are not relevant */
|
||||
static const uint8_t u8g_dev_t6963_128x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x021, /* set cursor position */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x022, /* set offset */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x040, /* text home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x041, /* text columns */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x042, /* graphics home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x043, /* graphics columns */
|
||||
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x080, /* mode register: OR Mode, Internal Character Mode */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
0x098, /* mode register: Display Mode, Graphics on, Text off, Cursor off */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x024, /* set adr pointer */
|
||||
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_t6963_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_128x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < PAGE_HEIGHT; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr&255 ); /* address low byte */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr>>8 ); /* address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x024 ); /* set adr ptr */
|
||||
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
// U8G_PB_DEV(u8g_dev_t6963_128x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_128x64_fn, U8G_COM_T6963);
|
||||
|
||||
uint8_t u8g_dev_t6963_128x64_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_t6963_128x64_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_t6963_128x64_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_t6963_128x64_8bit = { u8g_dev_t6963_128x64_fn, &u8g_dev_t6963_128x64_2x_bw_pb, U8G_COM_T6963 };
|
||||
|
||||
|
@ -1,195 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_t6963_240x128.c
|
||||
|
||||
Tested with Varitronix MGLS240128TZ
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, 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.
|
||||
|
||||
|
||||
Application Notes for the MGLS 240x128
|
||||
www.baso.no/content/pdf/T6963C_Application.pdf
|
||||
|
||||
Hitachi App Notes:
|
||||
https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
|
||||
|
||||
Notes:
|
||||
The font selection pins should generate the 8x8 font.
|
||||
For the MGLS240128TZ only FS1 is available on pin 18.
|
||||
FS1 must be low to generate the 8x8 font.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 16
|
||||
|
||||
|
||||
/*
|
||||
http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
|
||||
*/
|
||||
|
||||
/* text is not used, so settings are not relevant */
|
||||
static const uint8_t u8g_dev_t6963_240x128_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x021, /* set cursor position */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x022, /* set offset */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x040, /* text home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x041, /* text columns */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x042, /* graphics home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x043, /* graphics columns */
|
||||
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x080, /* mode register: OR Mode, Internal Character Mode */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
0x098, /* mode register: Display Mode, Graphics on, Text off, Cursor off */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x024, /* set adr pointer */
|
||||
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_t6963_240x128_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_240x128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < PAGE_HEIGHT; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr&255 ); /* address low byte */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr>>8 ); /* address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x024 ); /* set adr ptr */
|
||||
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
// U8G_PB_DEV(u8g_dev_t6963_240x128_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_240x128_fn, U8G_COM_T6963);
|
||||
|
||||
uint8_t u8g_dev_t6963_240x128_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_t6963_240x128_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_t6963_240x128_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_t6963_240x128_8bit = { u8g_dev_t6963_240x128_fn, &u8g_dev_t6963_240x128_2x_bw_pb, U8G_COM_T6963 };
|
||||
|
||||
|
@ -1,195 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_t6963_240x64.c
|
||||
|
||||
Tested with Varitronix MGLS240128TZ
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, 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.
|
||||
|
||||
|
||||
Application Notes for the MGLS 240x128
|
||||
www.baso.no/content/pdf/T6963C_Application.pdf
|
||||
|
||||
Hitachi App Notes:
|
||||
https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
|
||||
|
||||
Notes:
|
||||
The font selection pins should generate the 8x8 font.
|
||||
For the MGLS240128TZ only FS1 is available on pin 18.
|
||||
FS1 must be low to generate the 8x8 font.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 16
|
||||
|
||||
|
||||
/*
|
||||
http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
|
||||
*/
|
||||
|
||||
/* text is not used, so settings are not relevant */
|
||||
static const uint8_t u8g_dev_t6963_240x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x021, /* set cursor position */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x022, /* set offset */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x040, /* text home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x041, /* text columns */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x042, /* graphics home */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
WIDTH/8, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x043, /* graphics columns */
|
||||
|
||||
// mode set
|
||||
// 0x080: Internal CG, OR Mode
|
||||
// 0x081: Internal CG, EXOR Mode
|
||||
// 0x083: Internal CG, AND Mode
|
||||
// 0x088: External CG, OR Mode
|
||||
// 0x089: External CG, EXOR Mode
|
||||
// 0x08B: External CG, AND Mode
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x080, /* mode register: OR Mode, Internal Character Mode */
|
||||
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
// display mode
|
||||
// 0x090: Display off
|
||||
// 0x094: Graphic off, text on, cursor off, blink off
|
||||
// 0x096: Graphic off, text on, cursor on, blink off
|
||||
// 0x097: Graphic off, text on, cursor on, blink on
|
||||
// 0x098: Graphic on, text off, cursor off, blink off
|
||||
// 0x09a: Graphic on, text off, cursor on, blink off
|
||||
// ...
|
||||
// 0x09c: Graphic on, text on, cursor off, blink off
|
||||
// 0x09f: Graphic on, text on, cursor on, blink on
|
||||
0x098, /* mode register: Display Mode, Graphics on, Text off, Cursor off */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
0x000, /* low byte */
|
||||
0x000, /* height byte */
|
||||
U8G_ESC_ADR(1), /* instruction mode */
|
||||
0x024, /* set adr pointer */
|
||||
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
|
||||
U8G_ESC_ADR(0), /* data mode */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_t6963_240x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_NONE);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_240x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
uint8_t y, i;
|
||||
uint16_t disp_ram_adr;
|
||||
uint8_t *ptr;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
y = pb->p.page_y0;
|
||||
ptr = pb->buf;
|
||||
disp_ram_adr = WIDTH/8;
|
||||
disp_ram_adr *= y;
|
||||
for( i = 0; i < PAGE_HEIGHT; i ++ )
|
||||
{
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr&255 ); /* address low byte */
|
||||
u8g_WriteByte(u8g, dev, disp_ram_adr>>8 ); /* address hight byte */
|
||||
u8g_SetAddress(u8g, dev, 1); /* cmd mode */
|
||||
u8g_WriteByte(u8g, dev, 0x024 ); /* set adr ptr */
|
||||
|
||||
u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
|
||||
|
||||
ptr += WIDTH/8;
|
||||
disp_ram_adr += WIDTH/8;
|
||||
}
|
||||
u8g_SetAddress(u8g, dev, 0); /* data mode */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
// U8G_PB_DEV(u8g_dev_t6963_240x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_240x64_fn, U8G_COM_T6963);
|
||||
|
||||
uint8_t u8g_dev_t6963_240x64_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_t6963_240x64_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_t6963_240x64_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_t6963_240x64_8bit = { u8g_dev_t6963_240x64_fn, &u8g_dev_t6963_240x64_2x_bw_pb, U8G_COM_T6963 };
|
||||
|
||||
|
@ -1,115 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_tls8204_84x48.c
|
||||
|
||||
Display: Nokia 84x48
|
||||
|
||||
Status: Tested with TLS8204V12 Display by Olimex MOD-LCD3310
|
||||
|
||||
Contributed: http://code.google.com/p/u8glib/issues/detail?id=126
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 84
|
||||
#define HEIGHT 48
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_tls8204_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x021, /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
|
||||
0x006, /* temp. control: b10 = 2 */
|
||||
0x04 | !!((66-1)&(1u<<6)),
|
||||
0x40 | ((66-2) & ((1u<<6)-1)),
|
||||
0x013, /* bias system 1:48 */
|
||||
0x0c0, /* medium Vop */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal operation */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00d, /* display on, invert */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x020, /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
0x00c, /* display on, normal */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_tls8204_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_400NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_tls8204_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_SetAddress(u8g, dev, 0); /* command mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
|
||||
u8g_WriteByte(u8g, dev, 0x080 ); /* set X address */
|
||||
u8g_WriteByte(u8g, dev, 0x040 | pb->p.page); /* set Y address */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
/* the contrast adjustment does not work, needs to be analysed */
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_WriteByte(u8g, dev, 0x021); /* command mode, extended function set */
|
||||
u8g_WriteByte(u8g, dev, 0x080 | ( (*(uint8_t *)arg) >> 1 ) );
|
||||
u8g_WriteByte(u8g, dev, 0x020); /* command mode, extended function set */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
|
||||
U8G_PB_DEV(u8g_dev_tls8204_84x48_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_tls8204_fn, U8G_COM_SW_SPI);
|
||||
|
@ -1,201 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_uc1601_c128032.c
|
||||
|
||||
LCD-AG-C128032R-DIW W/KK E6 PBF from http://www.artronic.pl/o_produkcie.php?id=1343
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 32
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/* init sequence */
|
||||
static const uint8_t u8g_dev_uc1601_c128032_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
U8G_ESC_RST(15), /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
|
||||
|
||||
0x0a3, /* 0x0a3: LCD bias 1/7 , 0x0a2: LCD bias 1/9 */
|
||||
0x0a0, /* 0x0a0: ADC set to normal, 0x0a1 ADC set to inverted */
|
||||
0x0c8, /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
|
||||
0x0c2, /* 22 May 2013: mirror x */
|
||||
|
||||
0x040, /* set display start line */
|
||||
|
||||
0x028 | 0x04, /* power control: turn on voltage converter */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x06, /* power control: turn on voltage regulator */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x028 | 0x07, /* power control: turn on voltage follower */
|
||||
U8G_ESC_DLY(10), /* delay 10 ms */
|
||||
|
||||
0x020| 0x06, /* set V0 voltage resistor ratio to 6 */
|
||||
|
||||
0x0af, /* display on */
|
||||
|
||||
//0x081, /* set contrast */
|
||||
//0x018, /* contrast value*/
|
||||
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_uc1601_c128032_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x004, /* set lower 4 bit of the col adr */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_uc1601_c128032_sleep_on[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0ac, /* static indicator off */
|
||||
0x000, /* indicator register set (not sure if this is required) */
|
||||
0x0ae, /* display off */
|
||||
0x0a5, /* all points on */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_uc1601_c128032_sleep_off[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0a4, /* all points off */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
|
||||
uint8_t u8g_dev_uc1601_c128032_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1601_c128032_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1601_c128032_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (UC1601) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1601_c128032_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1601_c128032_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1601_c128032_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1601_c128032_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1601_c128032_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page (UC1601) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1601_c128032_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page (UC1601) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_ON:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1601_c128032_sleep_on);
|
||||
return 1;
|
||||
case U8G_DEV_MSG_SLEEP_OFF:
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1601_c128032_sleep_off);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1601_c128032_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1601_c128032_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1601_c128032_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1601_c128032_fn, U8G_COM_HW_SPI);
|
||||
|
||||
uint8_t u8g_dev_uc1601_c128032_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_uc1601_c128032_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_uc1601_c128032_2x_buf};
|
||||
u8g_dev_t u8g_dev_uc1601_c128032_2x_sw_spi = { u8g_dev_uc1601_c128032_2x_fn, &u8g_dev_uc1601_c128032_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_uc1601_c128032_2x_hw_spi = { u8g_dev_uc1601_c128032_2x_fn, &u8g_dev_uc1601_c128032_2x_pb, U8G_COM_HW_SPI };
|
||||
|
@ -1,200 +0,0 @@
|
||||
/*
|
||||
|
||||
|
||||
|
||||
u8g_dev_uc1608_240x128.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, olikraus@gmail.com (original 240x64 library)
|
||||
Modified by thieringpeti@gmail.com for Raystar rx240128 family displays
|
||||
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.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
Display: http://www.tme.eu/en/details/rx240128a-ghw/lcd-graphic-displays/raystar-optronics/
|
||||
Connection: HW / SW SPI.
|
||||
To get this display working, You need some extra capacitors:
|
||||
|
||||
connect 4.7uF caps between:
|
||||
PIN1 & PIN2 VB1 +-
|
||||
PIN3 & PIN4 VB0 -+
|
||||
connect 0.1uF caps between:
|
||||
VLCD and VSS
|
||||
VBIAS and VSS
|
||||
You can find some schematics with a 10M resistor parallellized with the VLCD capacitor.
|
||||
|
||||
Select 4-bit SPI mode.
|
||||
|
||||
Connect D7 (PIN9) To VDD (+3.3V)
|
||||
Connect D1, D2, D4, D5, D6 to GND (PINS 10,11,12,14,15)
|
||||
Connect WR0, WR1, BM0, BM1 to GND (PINS 17,18,22,23)
|
||||
|
||||
D0: (PIN16) AVR's SCK pin (HW SPI)
|
||||
D3: (PIN13) AVR's MOSI pin (HW SPI)
|
||||
CD: (PIN19) used as A0 in the library
|
||||
CS: (PIN21) Connect to the defined CS pin, and You can re-use the HW SPI in different routines.
|
||||
RST: (PIN20) optional reset, can be defined in the function, resets on initialization.
|
||||
|
||||
Adjust contrast if necessary. Default: 0x072.
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/* see also ERC24064-1 for init sequence example */
|
||||
static const uint8_t u8g_dev_uc1608_240x128_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(1), /* disable chip (UC1608 has positive logic for CS) */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (15*16)+2 milliseconds */
|
||||
|
||||
|
||||
U8G_ESC_CS(0), /* enable chip */
|
||||
0x0e2, /* soft reset */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x026, /* MUX rate and temperature compensation */
|
||||
|
||||
0x0c8, /* Map control, Bit 3: MY=1, Bit 2: MX=0, Bit 0: MSF =0 */
|
||||
|
||||
0x0eb, /* LCD bias Bits 0/1: 00=10.7 01=10.3, 10=12.0, 11=12.7*/
|
||||
/* default 0x0ea for 240x128 */
|
||||
0x081, /* set contrast (bits 0..5) and gain (bits 6/7) */
|
||||
0x072, /* default for 240x128 displays: 0x072*/
|
||||
|
||||
0x02f, /* power on, Bit 2 PC2=1 (internal charge pump), Bits 0/1: cap of panel */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x040, /* set display start line to 0 */
|
||||
0x090, /* no fixed lines */
|
||||
0x089, /* RAM access control */
|
||||
|
||||
0x0af, /* disable sleep mode */
|
||||
0x0a4, /* normal display */
|
||||
0x0a5, /* display all points, ST7565, UC1610 */
|
||||
// 0x0a7, /* inverse display */
|
||||
0x0a6, /* normal display */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_uc1608_240x128_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(0), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 (UC1608) */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_uc1608_240x128_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1608_240x128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1608_240x128_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (UC1608) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2); /* set contrast from, keep gain at 0 */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1608_240x128_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1608_240x128_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1608_240x128_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1608_240x128_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1608_240x128_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1608_240x128_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1608_240x128_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1608_240x128_fn, U8G_COM_HW_SPI);
|
||||
|
||||
uint8_t u8g_dev_uc1608_240x128_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_uc1608_240x128_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_uc1608_240x128_2x_buf};
|
||||
u8g_dev_t u8g_dev_uc1608_240x128_2x_sw_spi = { u8g_dev_uc1608_240x128_2x_fn, &u8g_dev_uc1608_240x128_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_uc1608_240x128_2x_hw_spi = { u8g_dev_uc1608_240x128_2x_fn, &u8g_dev_uc1608_240x128_2x_pb, U8G_COM_HW_SPI };
|
||||
|
@ -1,168 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_uc1608_240x64.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2013, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
/* see also ERC24064-1 for init sequence example */
|
||||
static const uint8_t u8g_dev_uc1608_240x64_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(1), /* disable chip (UC1608 has positive logic for CS) */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (15*16)+2 milliseconds */
|
||||
|
||||
|
||||
U8G_ESC_CS(0), /* enable chip */
|
||||
0x0e2, /* soft reset */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
#if HEIGHT <= 96
|
||||
0x023, /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
#else
|
||||
/* 30 Nov 2013: not tested */
|
||||
0x027, /* Bit 0/1: Temp compenstation, Bit 2: Multiplex Rate 0=96, 1=128 */
|
||||
#endif
|
||||
0x0c8, /* Map control, Bit 3: MY=1, Bit 2: MX=0, Bit 0: MSF =0 */
|
||||
0x0e8, /* LCD bias Bits 0/1: 00=10.7 01=10.3, 10=12.0, 11=12.7*/
|
||||
|
||||
0x081, /* set contrast (bits 0..5) and gain (bits 6/7) */
|
||||
0x014, /* ECR24064-1 default: 0x040*/
|
||||
|
||||
0x02f, /* power on, Bit 2 PC2=1 (internal charge pump), Bits 0/1: cap of panel */
|
||||
U8G_ESC_DLY(50), /* delay 50 ms */
|
||||
|
||||
0x040, /* set display start line to 0 */
|
||||
0x090, /* no fixed lines */
|
||||
0x089, /* RAM access control */
|
||||
|
||||
0x0af, /* disable sleep mode */
|
||||
0x0a4, /* normal display */
|
||||
0x0a5, /* display all points, ST7565, UC1610 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(1), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_uc1608_240x64_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(0), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 (UC1608) */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_uc1608_240x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1608_240x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1608_240x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (UC1608) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2); /* set contrast from, keep gain at 0 */
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1608_240x64_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1608_240x64_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1608_240x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1608_240x64_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1608_240x64_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1608_240x64_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1608_240x64_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1608_240x64_fn, U8G_COM_HW_SPI);
|
||||
|
||||
uint8_t u8g_dev_uc1608_240x64_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_uc1608_240x64_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_uc1608_240x64_2x_buf};
|
||||
u8g_dev_t u8g_dev_uc1608_240x64_2x_sw_spi = { u8g_dev_uc1608_240x64_2x_fn, &u8g_dev_uc1608_240x64_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_uc1608_240x64_2x_hw_spi = { u8g_dev_uc1608_240x64_2x_fn, &u8g_dev_uc1608_240x64_2x_pb, U8G_COM_HW_SPI };
|
||||
|
@ -1,290 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_uc1610_dogxl160.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 160
|
||||
#define HEIGHT 104
|
||||
|
||||
static const uint8_t u8g_dev_uc1610_dogxl160_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x0f1, /* set display height-1 */
|
||||
0x067, /* */
|
||||
0x0c0, /* SEG & COM normal */
|
||||
0x040, /* set display start line */
|
||||
0x050, /* */
|
||||
0x02b, /* set panelloading */
|
||||
0x0eb, /* set bias 1/2 */
|
||||
0x081, /* set contrast */
|
||||
0x05f, /* */
|
||||
0x089, /* set auto increment */
|
||||
0x0a6, /* normal pixel mode */
|
||||
0x0d3, /* 0xd3=40% RMS separation for gray levels */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565, UC1610 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
|
||||
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_uc1610_dogxl160_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static uint8_t u8g_dev_1to2(uint8_t n)
|
||||
{
|
||||
register uint8_t a,b,c;
|
||||
a = n;
|
||||
a &= 1;
|
||||
n <<= 1;
|
||||
b = n;
|
||||
b &= 4;
|
||||
n <<= 1;
|
||||
c = n;
|
||||
c &= 16;
|
||||
n <<= 1;
|
||||
n &= 64;
|
||||
n |= a;
|
||||
n |= b;
|
||||
n |= c;
|
||||
n |= n << 1;
|
||||
return n;
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
int i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2) ); /* select current page 1/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] ) );
|
||||
}
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2+1) ); /* select current page 2/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] >> 4 ) );
|
||||
}
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page) ); /* select current page (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
int i;
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4) ); /* select current page 1/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] ) );
|
||||
}
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4+1) ); /* select current page 2/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] >> 4 ) );
|
||||
}
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4+2) ); /* select current page 1/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)((uint8_t *)(pb->buf)+WIDTH))[i] ) );
|
||||
}
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4+3) ); /* select current page 2/2 (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
for( i = 0; i < WIDTH; i++ )
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)((uint8_t *)(pb->buf)+WIDTH))[i] >> 4 ) );
|
||||
}
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2) ); /* select current page (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_WriteSequence(u8g, dev, WIDTH, pb->buf) == 0 )
|
||||
return 0;
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2+1) ); /* select current page (UC1610) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_WriteSequence(u8g, dev, WIDTH, (uint8_t *)(pb->buf)+WIDTH) == 0 )
|
||||
return 0;
|
||||
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v2_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1610_dogxl160_bw_sw_spi, WIDTH, HEIGHT, 8, u8g_dev_uc1610_dogxl160_bw_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1610_dogxl160_bw_hw_spi, WIDTH, HEIGHT, 8, u8g_dev_uc1610_dogxl160_bw_fn, U8G_COM_HW_SPI);
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1610_dogxl160_gr_sw_spi, WIDTH, HEIGHT, 4, u8g_dev_uc1610_dogxl160_gr_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1610_dogxl160_gr_hw_spi, WIDTH, HEIGHT, 4, u8g_dev_uc1610_dogxl160_gr_fn, U8G_COM_HW_SPI);
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_2x_bw_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_uc1610_dogxl160_2x_bw_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_uc1610_dogxl160_2x_bw_buf};
|
||||
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_sw_spi = { u8g_dev_uc1610_dogxl160_2x_bw_fn, &u8g_dev_uc1610_dogxl160_2x_bw_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_hw_spi = { u8g_dev_uc1610_dogxl160_2x_bw_fn, &u8g_dev_uc1610_dogxl160_2x_bw_pb, U8G_COM_HW_SPI };
|
||||
|
||||
uint8_t u8g_dev_uc1610_dogxl160_2x_gr_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_uc1610_dogxl160_2x_gr_pb = { {8, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_uc1610_dogxl160_2x_gr_buf};
|
||||
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_sw_spi = { u8g_dev_uc1610_dogxl160_2x_gr_fn, &u8g_dev_uc1610_dogxl160_2x_gr_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_hw_spi = { u8g_dev_uc1610_dogxl160_2x_gr_fn, &u8g_dev_uc1610_dogxl160_2x_gr_pb, U8G_COM_HW_SPI };
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_uc1611_dogm240.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2014, dev.menges.jonas@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 "u8g.h"
|
||||
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_uc1611_dogm240_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_DLY(200),
|
||||
U8G_ESC_CS(1), // enable chip
|
||||
U8G_ESC_ADR(0), // instruction mode
|
||||
0xe2, // system reset
|
||||
U8G_ESC_DLY(1),
|
||||
0x2f, // enable internal charge pump
|
||||
|
||||
0xF1, // set last COM electrode
|
||||
0x3F, // 64-1=63
|
||||
0xF2, // set display start line
|
||||
0x00, // 0
|
||||
0xF3, // set display end line
|
||||
0x3F, // 64-1=63
|
||||
0x81, // set contrast (0-255)
|
||||
0xB7, // 183
|
||||
0xC0, // set view
|
||||
//0x04, // topview
|
||||
0x02, // bottomview
|
||||
0xA3, // set line rate (9.4k)
|
||||
0xE9, // set bias ratio (10)
|
||||
0xA9, // enable display
|
||||
0xD1, // set black and white mode
|
||||
U8G_ESC_CS(0), // disable chip
|
||||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
static void setPage(u8g_t *u8g, u8g_dev_t *dev, unsigned char page)
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, 0x70 + (page>>4));
|
||||
u8g_WriteByte(u8g, dev, 0x60 + (page&0x0F));
|
||||
}
|
||||
|
||||
static const uint8_t u8g_dev_uc1611_dogm240_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x10, /* set upper 4 bit of the col adr to 0 */
|
||||
0x00, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_uc1611_dogm240_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1611_dogm240_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1611_dogm240_data_start);
|
||||
setPage(u8g, dev, pb->p.page); /* select current page (uc1611) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x81);
|
||||
/* 11 Jul 2015: bugfix, github issue 339 */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); /* set contrast from, keep gain at 0 */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogm240_i2c , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogm240_fn, U8G_COM_UC_I2C);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogm240_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogm240_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogm240_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogm240_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogm240_8bit , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogm240_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_uc1611_dogxl240.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2014, dev.menges.jonas@gmail.com, 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 "u8g.h"
|
||||
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 128
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
|
||||
static const uint8_t u8g_dev_uc1611_dogxl240_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_DLY(200),
|
||||
U8G_ESC_CS(1), // enable chip
|
||||
U8G_ESC_ADR(0), // instruction mode
|
||||
|
||||
0xe2, // system reset
|
||||
U8G_ESC_DLY(1),
|
||||
0x2f, // enable internal charge pump
|
||||
|
||||
0xF1, // set last COM electrode
|
||||
0x7F, // DOGXL240
|
||||
0xF2, // set display start line
|
||||
0x00, // 0
|
||||
0xF3, // set display end line
|
||||
0x7F, // DOGXL240
|
||||
0x81, // set contrast (0-255)
|
||||
0xAA, // DOGXL240
|
||||
0xC0, // set view
|
||||
//0x04, // topview
|
||||
0x02, // bottomview
|
||||
0xA3, // set line rate (9.4k)
|
||||
0xE9, // set bias ratio (10)
|
||||
0xA9, // enable display
|
||||
0xD1, // set black and white mode
|
||||
U8G_ESC_CS(0), // disable chip
|
||||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
static void u8g_dev_dogxl240_set_page(u8g_t *u8g, u8g_dev_t *dev, unsigned char page)
|
||||
{
|
||||
u8g_WriteByte(u8g, dev, 0x70);
|
||||
u8g_WriteByte(u8g, dev, 0x60 + (page&0x0F));
|
||||
}
|
||||
|
||||
static const uint8_t u8g_dev_uc1611_dogxl240_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x10, /* set upper 4 bit of the col adr to 0 */
|
||||
0x00, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static uint8_t u8g_dev_uc1611_dogxl240_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1611_dogxl240_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1611_dogxl240_data_start);
|
||||
u8g_dev_dogxl240_set_page(u8g, dev, pb->p.page); /* select current page (uc1611) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x81);
|
||||
/* 11 Jul 2015: bugfix, github issue 339 */
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) ); /* set contrast from, keep gain at 0 */
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogxl240_i2c , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogxl240_fn, U8G_COM_UC_I2C);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogxl240_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogxl240_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogxl240_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogxl240_fn, U8G_COM_HW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1611_dogxl240_8bit , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1611_dogxl240_fn, U8G_COM_FAST_PARALLEL);
|
||||
|
@ -1,157 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_uc1701_dogs102.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 102
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_dogs102_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0e2, /* soft reset */
|
||||
0x040, /* set display start line to 0 */
|
||||
0x0a1, /* ADC set to reverse */
|
||||
0x0c0, /* common output mode */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x027, /* regulator, booster and follower */
|
||||
0x081, /* set contrast */
|
||||
0x00e, /* contrast value, EA default: 0x010, previous value for S102: 0x0e */
|
||||
0x0fa, /* Set Temp compensation */
|
||||
0x090, /* 0.11 deg/c WP Off WC Off*/
|
||||
0x0a4, /* normal display */
|
||||
0x0af, /* display on */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565, UC1610 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_dogs102_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 0 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_dogs102_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_dogs102_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_dogs102_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1701_dogs102_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_dogs102_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_dogs102_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_dogs102_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page (ST7565R) */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1701_dogs102_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_dogs102_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1701_dogs102_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_dogs102_fn, U8G_COM_HW_SPI);
|
||||
|
||||
uint8_t u8g_dev_uc1701_dogs102_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_uc1701_dogs102_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_uc1701_dogs102_2x_buf};
|
||||
u8g_dev_t u8g_dev_uc1701_dogs102_2x_sw_spi = { u8g_dev_uc1701_dogs102_2x_fn, &u8g_dev_uc1701_dogs102_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_uc1701_dogs102_2x_hw_spi = { u8g_dev_uc1701_dogs102_2x_fn, &u8g_dev_uc1701_dogs102_2x_pb, U8G_COM_HW_SPI };
|
||||
|
@ -1,158 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_dev_uc1701_mini12864.c (dealextreme)
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
#define WIDTH 128
|
||||
#define HEIGHT 64
|
||||
#define PAGE_HEIGHT 8
|
||||
|
||||
static const uint8_t u8g_dev_uc1701_mini12864_init_seq[] PROGMEM = {
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_RST(1), /* do reset low pulse with (1*16)+2 milliseconds */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
|
||||
0x0e2, /* soft reset */
|
||||
0x040, /* set display start line to 0 */
|
||||
0x0a0, /* ADC set to reverse */
|
||||
0x0c8, /* common output mode */
|
||||
0x0a6, /* display normal, bit val 0: LCD pixel off. */
|
||||
0x0a2, /* LCD bias 1/9 */
|
||||
0x02f, /* all power control circuits on */
|
||||
0x0f8, /* set booster ratio to */
|
||||
0x000, /* 4x */
|
||||
0x023, /* set V0 voltage resistor ratio to large */
|
||||
0x081, /* set contrast */
|
||||
0x027, /* contrast value */
|
||||
0x0ac, /* indicator */
|
||||
0x000, /* disable */
|
||||
0x0af, /* display on */
|
||||
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a5, /* display all points, ST7565 */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
U8G_ESC_DLY(100), /* delay 100 ms */
|
||||
0x0a4, /* normal display */
|
||||
U8G_ESC_CS(0), /* disable chip */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
static const uint8_t u8g_dev_uc1701_mini12864_data_start[] PROGMEM = {
|
||||
U8G_ESC_ADR(0), /* instruction mode */
|
||||
U8G_ESC_CS(1), /* enable chip */
|
||||
0x010, /* set upper 4 bit of the col adr to 0 */
|
||||
0x000, /* set lower 4 bit of the col adr to 4 */
|
||||
U8G_ESC_END /* end of sequence */
|
||||
};
|
||||
|
||||
uint8_t u8g_dev_uc1701_mini12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
|
||||
return 0;
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_uc1701_mini12864_2x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_INIT:
|
||||
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_init_seq);
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page)); /* select current page */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, pb->buf);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
|
||||
u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_data_start);
|
||||
u8g_WriteByte(u8g, dev, 0x0b0 | (2*pb->p.page+1)); /* select current page */
|
||||
u8g_SetAddress(u8g, dev, 1); /* data mode */
|
||||
u8g_WriteSequence(u8g, dev, pb->width, (uint8_t *)(pb->buf)+pb->width);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_CONTRAST:
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_SetAddress(u8g, dev, 0); /* instruction mode */
|
||||
u8g_WriteByte(u8g, dev, 0x081);
|
||||
u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
|
||||
u8g_SetChipSelect(u8g, dev, 0);
|
||||
return 1;
|
||||
}
|
||||
return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
U8G_PB_DEV(u8g_dev_uc1701_mini12864_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1701_mini12864_fn, U8G_COM_SW_SPI);
|
||||
U8G_PB_DEV(u8g_dev_uc1701_mini12864_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1701_mini12864_fn, U8G_COM_HW_SPI);
|
||||
|
||||
uint8_t u8g_dev_uc1701_mini12864_2x_buf[WIDTH*2] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_dev_uc1701_mini12864_2x_pb = { {16, HEIGHT, 0, 0, 0}, WIDTH, u8g_dev_uc1701_mini12864_2x_buf};
|
||||
u8g_dev_t u8g_dev_uc1701_mini12864_2x_sw_spi = { u8g_dev_uc1701_mini12864_2x_fn, &u8g_dev_uc1701_mini12864_2x_pb, U8G_COM_SW_SPI };
|
||||
u8g_dev_t u8g_dev_uc1701_mini12864_2x_hw_spi = { u8g_dev_uc1701_mini12864_2x_fn, &u8g_dev_uc1701_mini12864_2x_pb, U8G_COM_HW_SPI };
|
@ -1,393 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_ellipse.c
|
||||
|
||||
Utility to draw empty and filled ellipses.
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, bjthom@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.
|
||||
|
||||
Addition to the U8G Library as of 02/29/12
|
||||
Adapted from Bresenham's Algorithm and the following websites:
|
||||
http://free.pages.at/easyfilter/bresenham.html
|
||||
http://homepage.smc.edu/kennedy_john/belipse.pdf
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
|
||||
#ifdef WORK_IN_PROGRESS
|
||||
|
||||
void u8g_DrawEllipseRect(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t x1, u8g_uint_t y1)
|
||||
{
|
||||
int a = abs(x1 - x0);
|
||||
int b = abs(y1 - y0); //get diameters
|
||||
int b1 = b&1;
|
||||
long dx = 4*(1-a)*b*b;
|
||||
long dy = 4*(b1+1)*a*a;
|
||||
long err = dx+dy+b1*a*a;
|
||||
long e2;
|
||||
|
||||
if (x0 > x1) { x0 = x1; x1 += a; }
|
||||
if (y0 > y1) { y0 = y1; }
|
||||
y0 += (b+1)/2;
|
||||
y1 = y0-b1;
|
||||
a *= 8*a;
|
||||
b1 = 8*b*b;
|
||||
|
||||
do {
|
||||
u8g_DrawPixel(u8g, x1, y0);
|
||||
u8g_DrawPixel(u8g, x0, y0);
|
||||
u8g_DrawPixel(u8g, x0, y1);
|
||||
u8g_DrawPixel(u8g, x1, y1);
|
||||
e2 = 2*err;
|
||||
if (e2 >= dx) {
|
||||
x0++;
|
||||
x1--;
|
||||
err += dx += b1;
|
||||
}
|
||||
if (e2 <= dy) {
|
||||
y0++;
|
||||
y1--;
|
||||
err += dy += a;
|
||||
}
|
||||
} while (x0 <= x1);
|
||||
|
||||
while (y0-y1 < b) {
|
||||
u8g_DrawPixel(u8g, x0-1, y0);
|
||||
u8g_DrawPixel(u8g, x1+1, y0++);
|
||||
u8g_DrawPixel(u8g, x0-1, y1);
|
||||
u8g_DrawPixel(u8g, x1+1, y1--);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_DrawEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t xr, u8g_uint_t yr)
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0, y0+yr);
|
||||
u8g_DrawPixel(u8g, x0, y0-yr);
|
||||
u8g_DrawPixel(u8g, x0+xr, y0);
|
||||
u8g_DrawPixel(u8g, x0-xr, y0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(U8G_16BIT)
|
||||
typedef int32_t u8g_long_t;
|
||||
#else
|
||||
typedef int16_t u8g_long_t;
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Source:
|
||||
ftp://pc.fk0.name/pub/books/programming/bezier-ellipse.pdf
|
||||
Foley, Computer Graphics, p 90
|
||||
*/
|
||||
static void u8g_draw_ellipse_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option) U8G_NOINLINE;
|
||||
static void u8g_draw_ellipse_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option)
|
||||
{
|
||||
/* upper right */
|
||||
if ( option & U8G_DRAW_UPPER_RIGHT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 + x, y0 - y);
|
||||
}
|
||||
|
||||
/* upper left */
|
||||
if ( option & U8G_DRAW_UPPER_LEFT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 - x, y0 - y);
|
||||
}
|
||||
|
||||
/* lower right */
|
||||
if ( option & U8G_DRAW_LOWER_RIGHT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 + x, y0 + y);
|
||||
}
|
||||
|
||||
/* lower left */
|
||||
if ( option & U8G_DRAW_LOWER_LEFT )
|
||||
{
|
||||
u8g_DrawPixel(u8g, x0 - x, y0 + y);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_draw_ellipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option)
|
||||
{
|
||||
u8g_uint_t x, y;
|
||||
u8g_long_t xchg, ychg;
|
||||
u8g_long_t err;
|
||||
u8g_long_t rxrx2;
|
||||
u8g_long_t ryry2;
|
||||
u8g_long_t stopx, stopy;
|
||||
|
||||
rxrx2 = rx;
|
||||
rxrx2 *= rx;
|
||||
rxrx2 *= 2;
|
||||
|
||||
ryry2 = ry;
|
||||
ryry2 *= ry;
|
||||
ryry2 *= 2;
|
||||
|
||||
x = rx;
|
||||
y = 0;
|
||||
|
||||
xchg = 1;
|
||||
xchg -= rx;
|
||||
xchg -= rx;
|
||||
xchg *= ry;
|
||||
xchg *= ry;
|
||||
|
||||
ychg = rx;
|
||||
ychg *= rx;
|
||||
|
||||
err = 0;
|
||||
|
||||
stopx = ryry2;
|
||||
stopx *= rx;
|
||||
stopy = 0;
|
||||
|
||||
while( stopx >= stopy )
|
||||
{
|
||||
u8g_draw_ellipse_section(u8g, x, y, x0, y0, option);
|
||||
y++;
|
||||
stopy += rxrx2;
|
||||
err += ychg;
|
||||
ychg += rxrx2;
|
||||
if ( 2*err+xchg > 0 )
|
||||
{
|
||||
x--;
|
||||
stopx -= ryry2;
|
||||
err += xchg;
|
||||
xchg += ryry2;
|
||||
}
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y = ry;
|
||||
|
||||
xchg = ry;
|
||||
xchg *= ry;
|
||||
|
||||
ychg = 1;
|
||||
ychg -= ry;
|
||||
ychg -= ry;
|
||||
ychg *= rx;
|
||||
ychg *= rx;
|
||||
|
||||
err = 0;
|
||||
|
||||
stopx = 0;
|
||||
|
||||
stopy = rxrx2;
|
||||
stopy *= ry;
|
||||
|
||||
|
||||
while( stopx <= stopy )
|
||||
{
|
||||
u8g_draw_ellipse_section(u8g, x, y, x0, y0, option);
|
||||
x++;
|
||||
stopx += ryry2;
|
||||
err += xchg;
|
||||
xchg += ryry2;
|
||||
if ( 2*err+ychg > 0 )
|
||||
{
|
||||
y--;
|
||||
stopy -= rxrx2;
|
||||
err += ychg;
|
||||
ychg += rxrx2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void u8g_DrawEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option)
|
||||
{
|
||||
/* check for bounding box */
|
||||
{
|
||||
u8g_uint_t rxp, rxp2;
|
||||
u8g_uint_t ryp, ryp2;
|
||||
|
||||
rxp = rx;
|
||||
rxp++;
|
||||
rxp2 = rxp;
|
||||
rxp2 *= 2;
|
||||
|
||||
ryp = ry;
|
||||
ryp++;
|
||||
ryp2 = ryp;
|
||||
ryp2 *= 2;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x0-rxp, y0-ryp, rxp2, ryp2) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
u8g_draw_ellipse(u8g, x0, y0, rx, ry, option);
|
||||
}
|
||||
|
||||
static void u8g_draw_filled_ellipse_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option) U8G_NOINLINE;
|
||||
static void u8g_draw_filled_ellipse_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option)
|
||||
{
|
||||
/* upper right */
|
||||
if ( option & U8G_DRAW_UPPER_RIGHT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0+x, y0-y, y+1);
|
||||
}
|
||||
|
||||
/* upper left */
|
||||
if ( option & U8G_DRAW_UPPER_LEFT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0-x, y0-y, y+1);
|
||||
}
|
||||
|
||||
/* lower right */
|
||||
if ( option & U8G_DRAW_LOWER_RIGHT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0+x, y0, y+1);
|
||||
}
|
||||
|
||||
/* lower left */
|
||||
if ( option & U8G_DRAW_LOWER_LEFT )
|
||||
{
|
||||
u8g_DrawVLine(u8g, x0-x, y0, y+1);
|
||||
}
|
||||
}
|
||||
|
||||
void u8g_draw_filled_ellipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option)
|
||||
{
|
||||
u8g_uint_t x, y;
|
||||
u8g_long_t xchg, ychg;
|
||||
u8g_long_t err;
|
||||
u8g_long_t rxrx2;
|
||||
u8g_long_t ryry2;
|
||||
u8g_long_t stopx, stopy;
|
||||
|
||||
rxrx2 = rx;
|
||||
rxrx2 *= rx;
|
||||
rxrx2 *= 2;
|
||||
|
||||
ryry2 = ry;
|
||||
ryry2 *= ry;
|
||||
ryry2 *= 2;
|
||||
|
||||
x = rx;
|
||||
y = 0;
|
||||
|
||||
xchg = 1;
|
||||
xchg -= rx;
|
||||
xchg -= rx;
|
||||
xchg *= ry;
|
||||
xchg *= ry;
|
||||
|
||||
ychg = rx;
|
||||
ychg *= rx;
|
||||
|
||||
err = 0;
|
||||
|
||||
stopx = ryry2;
|
||||
stopx *= rx;
|
||||
stopy = 0;
|
||||
|
||||
while( stopx >= stopy )
|
||||
{
|
||||
u8g_draw_filled_ellipse_section(u8g, x, y, x0, y0, option);
|
||||
y++;
|
||||
stopy += rxrx2;
|
||||
err += ychg;
|
||||
ychg += rxrx2;
|
||||
if ( 2*err+xchg > 0 )
|
||||
{
|
||||
x--;
|
||||
stopx -= ryry2;
|
||||
err += xchg;
|
||||
xchg += ryry2;
|
||||
}
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y = ry;
|
||||
|
||||
xchg = ry;
|
||||
xchg *= ry;
|
||||
|
||||
ychg = 1;
|
||||
ychg -= ry;
|
||||
ychg -= ry;
|
||||
ychg *= rx;
|
||||
ychg *= rx;
|
||||
|
||||
err = 0;
|
||||
|
||||
stopx = 0;
|
||||
|
||||
stopy = rxrx2;
|
||||
stopy *= ry;
|
||||
|
||||
|
||||
while( stopx <= stopy )
|
||||
{
|
||||
u8g_draw_filled_ellipse_section(u8g, x, y, x0, y0, option);
|
||||
x++;
|
||||
stopx += ryry2;
|
||||
err += xchg;
|
||||
xchg += ryry2;
|
||||
if ( 2*err+ychg > 0 )
|
||||
{
|
||||
y--;
|
||||
stopy -= rxrx2;
|
||||
err += ychg;
|
||||
ychg += rxrx2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void u8g_DrawFilledEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rx, u8g_uint_t ry, uint8_t option)
|
||||
{
|
||||
/* check for bounding box */
|
||||
{
|
||||
u8g_uint_t rxp, rxp2;
|
||||
u8g_uint_t ryp, ryp2;
|
||||
|
||||
rxp = rx;
|
||||
rxp++;
|
||||
rxp2 = rxp;
|
||||
rxp2 *= 2;
|
||||
|
||||
ryp = ry;
|
||||
ryp++;
|
||||
ryp2 = ryp;
|
||||
ryp2 *= 2;
|
||||
|
||||
if ( u8g_IsBBXIntersection(u8g, x0-rxp, y0-ryp, rxp2, ryp2) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
u8g_draw_filled_ellipse(u8g, x0, y0, rx, ry, option);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,90 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_line.c
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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 "u8g.h"
|
||||
|
||||
void u8g_DrawLine(u8g_t *u8g, u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_uint_t y2)
|
||||
{
|
||||
u8g_uint_t tmp;
|
||||
u8g_uint_t x,y;
|
||||
u8g_uint_t dx, dy;
|
||||
u8g_int_t err;
|
||||
u8g_int_t ystep;
|
||||
|
||||
uint8_t swapxy = 0;
|
||||
|
||||
/* no BBX intersection check at the moment, should be added... */
|
||||
|
||||
if ( x1 > x2 ) dx = x1-x2; else dx = x2-x1;
|
||||
if ( y1 > y2 ) dy = y1-y2; else dy = y2-y1;
|
||||
|
||||
if ( dy > dx )
|
||||
{
|
||||
swapxy = 1;
|
||||
tmp = dx; dx =dy; dy = tmp;
|
||||
tmp = x1; x1 =y1; y1 = tmp;
|
||||
tmp = x2; x2 =y2; y2 = tmp;
|
||||
}
|
||||
if ( x1 > x2 )
|
||||
{
|
||||
tmp = x1; x1 =x2; x2 = tmp;
|
||||
tmp = y1; y1 =y2; y2 = tmp;
|
||||
}
|
||||
err = dx >> 1;
|
||||
if ( y2 > y1 ) ystep = 1; else ystep = -1;
|
||||
y = y1;
|
||||
|
||||
#ifndef U8G_16BIT
|
||||
if ( x2 == 255 )
|
||||
x2--;
|
||||
#else
|
||||
if ( x2 == 0xffff )
|
||||
x2--;
|
||||
#endif
|
||||
|
||||
for( x = x1; x <= x2; x++ )
|
||||
{
|
||||
if ( swapxy == 0 )
|
||||
u8g_DrawPixel(u8g, x, y);
|
||||
else
|
||||
u8g_DrawPixel(u8g, y, x);
|
||||
err -= (uint8_t)dy;
|
||||
if ( err < 0 )
|
||||
{
|
||||
y += (u8g_uint_t)ystep;
|
||||
err += (u8g_uint_t)dx;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,581 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_ll_api.c
|
||||
|
||||
low level api
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 <stddef.h>
|
||||
#include "u8g.h"
|
||||
|
||||
uint8_t u8g_call_dev_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
return dev->dev_fn(u8g, dev, msg, arg);
|
||||
}
|
||||
|
||||
/*====================================================================*/
|
||||
|
||||
uint8_t u8g_InitLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t r;
|
||||
u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
|
||||
r = u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_INIT, NULL);
|
||||
u8g->state_cb(U8G_STATE_MSG_BACKUP_U8G);
|
||||
u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
|
||||
return r;
|
||||
}
|
||||
|
||||
void u8g_FirstPageLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
|
||||
u8g->state_cb(U8G_STATE_MSG_RESTORE_U8G);
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_FIRST, NULL);
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
|
||||
u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
|
||||
}
|
||||
|
||||
uint8_t u8g_NextPageLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
uint8_t r;
|
||||
u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
|
||||
u8g->state_cb(U8G_STATE_MSG_RESTORE_U8G);
|
||||
r = u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_NEXT, NULL);
|
||||
if ( r != 0 )
|
||||
{
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
|
||||
}
|
||||
u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
|
||||
return r;
|
||||
}
|
||||
|
||||
uint8_t u8g_SetContrastLL(u8g_t *u8g, u8g_dev_t *dev, uint8_t contrast)
|
||||
{
|
||||
return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_CONTRAST, &contrast);
|
||||
}
|
||||
|
||||
void u8g_DrawPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y)
|
||||
{
|
||||
u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
|
||||
arg->x = x;
|
||||
arg->y = y;
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_PIXEL, arg);
|
||||
}
|
||||
|
||||
void u8g_Draw8PixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
|
||||
{
|
||||
u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
|
||||
arg->x = x;
|
||||
arg->y = y;
|
||||
arg->dir = dir;
|
||||
arg->pixel = pixel;
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_8PIXEL, arg);
|
||||
}
|
||||
|
||||
void u8g_Draw4TPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
|
||||
{
|
||||
u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
|
||||
arg->x = x;
|
||||
arg->y = y;
|
||||
arg->dir = dir;
|
||||
arg->pixel = pixel;
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_4TPIXEL, arg);
|
||||
}
|
||||
|
||||
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
uint8_t u8g_IsBBXIntersectionLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
|
||||
{
|
||||
return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_IS_BBX_INTERSECTION, &arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
u8g_uint_t u8g_GetWidthLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
u8g_uint_t r;
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_WIDTH, &r);
|
||||
return r;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_GetHeightLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
u8g_uint_t r;
|
||||
u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_HEIGHT, &r);
|
||||
return r;
|
||||
}
|
||||
|
||||
u8g_uint_t u8g_GetModeLL(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_MODE, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*====================================================================*/
|
||||
|
||||
void u8g_UpdateDimension(u8g_t *u8g)
|
||||
{
|
||||
u8g->width = u8g_GetWidthLL(u8g, u8g->dev);
|
||||
u8g->height = u8g_GetHeightLL(u8g, u8g->dev);
|
||||
u8g->mode = u8g_GetModeLL(u8g, u8g->dev);
|
||||
/* 9 Dec 2012: u8g_scale.c requires update of current page */
|
||||
u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
|
||||
}
|
||||
|
||||
static void u8g_init_data(u8g_t *u8g)
|
||||
{
|
||||
u8g->font = NULL;
|
||||
u8g->cursor_font = NULL;
|
||||
u8g->cursor_bg_color = 0;
|
||||
u8g->cursor_fg_color = 1;
|
||||
u8g->cursor_encoding = 34;
|
||||
u8g->cursor_fn = (u8g_draw_cursor_fn)0;
|
||||
|
||||
#if defined(U8G_WITH_PINLIST)
|
||||
{
|
||||
uint8_t i;
|
||||
for( i = 0; i < U8G_PIN_LIST_LEN; i++ )
|
||||
u8g->pin_list[i] = U8G_PIN_NONE;
|
||||
}
|
||||
#endif
|
||||
|
||||
u8g_SetColorIndex(u8g, 1);
|
||||
|
||||
u8g_SetFontPosBaseline(u8g);
|
||||
|
||||
u8g->font_height_mode = U8G_FONT_HEIGHT_MODE_XTEXT;
|
||||
u8g->font_ref_ascent = 0;
|
||||
u8g->font_ref_descent = 0;
|
||||
u8g->font_line_spacing_factor = 64; /* 64 = 1.0, 77 = 1.2 line spacing factor */
|
||||
u8g->line_spacing = 0;
|
||||
|
||||
u8g->state_cb = u8g_state_dummy_cb;
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8g_Begin(u8g_t *u8g)
|
||||
{
|
||||
/* call and init low level driver and com device */
|
||||
if ( u8g_InitLL(u8g, u8g->dev) == 0 )
|
||||
return 0;
|
||||
/* fetch width and height from the low level */
|
||||
u8g_UpdateDimension(u8g);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_Init(u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
/* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
|
||||
/* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
|
||||
/* if Arduino call u8g_UpdateDimension else u8g_Begin */
|
||||
/* issue 146 */
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
/* special init for pure ARM systems */
|
||||
uint8_t u8g_InitComFn(u8g_t *u8g, u8g_dev_t *dev, u8g_com_fnptr com_fn)
|
||||
{
|
||||
u8g_init_data(u8g);
|
||||
|
||||
#if defined(U8G_WITH_PINLIST)
|
||||
{
|
||||
uint8_t i;
|
||||
for( i = 0; i < U8G_PIN_LIST_LEN; i++ )
|
||||
u8g->pin_list[i] = U8G_PIN_DUMMY;
|
||||
}
|
||||
#endif
|
||||
|
||||
u8g->dev = dev;
|
||||
|
||||
/* replace the device procedure with a custom communication procedure */
|
||||
u8g->dev->com_fn = com_fn;
|
||||
|
||||
/* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
|
||||
/* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
|
||||
/* if Arduino call u8g_UpdateDimension else u8g_Begin */
|
||||
/* issue 146 */
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
|
||||
#if defined(U8G_WITH_PINLIST)
|
||||
uint8_t u8g_InitSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset)
|
||||
{
|
||||
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
/* assign user pins */
|
||||
u8g->pin_list[U8G_PI_SCK] = sck;
|
||||
u8g->pin_list[U8G_PI_MOSI] = mosi;
|
||||
u8g->pin_list[U8G_PI_CS] = cs;
|
||||
u8g->pin_list[U8G_PI_A0] = a0;
|
||||
u8g->pin_list[U8G_PI_RESET] = reset;
|
||||
|
||||
/* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
|
||||
/* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
|
||||
/* if Arduino call u8g_UpdateDimension else u8g_Begin */
|
||||
/* issue 146 */
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
uint8_t u8g_InitHWSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset)
|
||||
{
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
|
||||
/* assign user pins */
|
||||
u8g->pin_list[U8G_PI_CS] = cs;
|
||||
u8g->pin_list[U8G_PI_A0] = a0;
|
||||
u8g->pin_list[U8G_PI_RESET] = reset;
|
||||
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
uint8_t u8g_InitI2C(u8g_t *u8g, u8g_dev_t *dev, uint8_t options)
|
||||
{
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
u8g->pin_list[U8G_PI_I2C_OPTION] = options;
|
||||
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_Init8BitFixedPort(u8g_t *u8g, u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset)
|
||||
{
|
||||
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
/* assign user pins */
|
||||
|
||||
u8g->pin_list[U8G_PI_EN] = en;
|
||||
u8g->pin_list[U8G_PI_CS] = cs;
|
||||
u8g->pin_list[U8G_PI_DI] = di;
|
||||
u8g->pin_list[U8G_PI_RW] = rw;
|
||||
u8g->pin_list[U8G_PI_RESET] = reset;
|
||||
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
uint8_t u8g_Init8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset)
|
||||
{
|
||||
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
/* assign user pins */
|
||||
|
||||
u8g->pin_list[U8G_PI_D0] = d0;
|
||||
u8g->pin_list[U8G_PI_D1] = d1;
|
||||
u8g->pin_list[U8G_PI_D2] = d2;
|
||||
u8g->pin_list[U8G_PI_D3] = d3;
|
||||
u8g->pin_list[U8G_PI_D4] = d4;
|
||||
u8g->pin_list[U8G_PI_D5] = d5;
|
||||
u8g->pin_list[U8G_PI_D6] = d6;
|
||||
u8g->pin_list[U8G_PI_D7] = d7;
|
||||
|
||||
u8g->pin_list[U8G_PI_EN] = en;
|
||||
u8g->pin_list[U8G_PI_CS1] = cs1;
|
||||
u8g->pin_list[U8G_PI_CS2] = cs2;
|
||||
u8g->pin_list[U8G_PI_DI] = di;
|
||||
u8g->pin_list[U8G_PI_RW] = rw;
|
||||
u8g->pin_list[U8G_PI_RESET] = reset;
|
||||
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
PIN_D0 8
|
||||
PIN_D1 9
|
||||
PIN_D2 10
|
||||
PIN_D3 11
|
||||
PIN_D4 4
|
||||
PIN_D5 5
|
||||
PIN_D6 6
|
||||
PIN_D7 7
|
||||
|
||||
PIN_CS 14
|
||||
PIN_A0 15
|
||||
PIN_RESET 16
|
||||
PIN_WR 17
|
||||
PIN_RD 18
|
||||
|
||||
u8g_InitRW8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
|
||||
u8g_InitRW8Bit(u8g, dev, 8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16)
|
||||
|
||||
*/
|
||||
|
||||
uint8_t u8g_InitRW8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7,
|
||||
uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset)
|
||||
{
|
||||
|
||||
/* fill data structure with some suitable values */
|
||||
u8g_init_data(u8g);
|
||||
u8g->dev = dev;
|
||||
|
||||
/* assign user pins */
|
||||
|
||||
u8g->pin_list[U8G_PI_D0] = d0;
|
||||
u8g->pin_list[U8G_PI_D1] = d1;
|
||||
u8g->pin_list[U8G_PI_D2] = d2;
|
||||
u8g->pin_list[U8G_PI_D3] = d3;
|
||||
u8g->pin_list[U8G_PI_D4] = d4;
|
||||
u8g->pin_list[U8G_PI_D5] = d5;
|
||||
u8g->pin_list[U8G_PI_D6] = d6;
|
||||
u8g->pin_list[U8G_PI_D7] = d7;
|
||||
|
||||
u8g->pin_list[U8G_PI_CS] = cs;
|
||||
u8g->pin_list[U8G_PI_A0] = a0;
|
||||
u8g->pin_list[U8G_PI_WR] = wr;
|
||||
u8g->pin_list[U8G_PI_RD] = rd;
|
||||
u8g->pin_list[U8G_PI_RESET] = reset;
|
||||
|
||||
return u8g_Begin(u8g);
|
||||
}
|
||||
#endif /* defined(U8G_WITH_PINLIST) */
|
||||
|
||||
void u8g_FirstPage(u8g_t *u8g)
|
||||
{
|
||||
u8g_FirstPageLL(u8g, u8g->dev);
|
||||
}
|
||||
|
||||
uint8_t u8g_NextPage(u8g_t *u8g)
|
||||
{
|
||||
if ( u8g->cursor_fn != (u8g_draw_cursor_fn)0 )
|
||||
{
|
||||
u8g->cursor_fn(u8g);
|
||||
}
|
||||
return u8g_NextPageLL(u8g, u8g->dev);
|
||||
}
|
||||
|
||||
uint8_t u8g_SetContrast(u8g_t *u8g, uint8_t contrast)
|
||||
{
|
||||
return u8g_SetContrastLL(u8g, u8g->dev, contrast);
|
||||
}
|
||||
|
||||
void u8g_SleepOn(u8g_t *u8g)
|
||||
{
|
||||
u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_ON, NULL);
|
||||
}
|
||||
|
||||
void u8g_SleepOff(u8g_t *u8g)
|
||||
{
|
||||
u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_OFF, NULL);
|
||||
}
|
||||
|
||||
|
||||
void u8g_DrawPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y)
|
||||
{
|
||||
u8g_DrawPixelLL(u8g, u8g->dev, x, y);
|
||||
}
|
||||
|
||||
void u8g_Draw8Pixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
|
||||
{
|
||||
u8g_Draw8PixelLL(u8g, u8g->dev, x, y, dir, pixel);
|
||||
}
|
||||
|
||||
void u8g_Draw4TPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
|
||||
{
|
||||
u8g_Draw4TPixelLL(u8g, u8g->dev, x, y, dir, pixel);
|
||||
}
|
||||
|
||||
void u8g_Draw8ColorPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t colpixel)
|
||||
{
|
||||
u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
|
||||
arg->x = x;
|
||||
arg->y = y;
|
||||
arg->dir = 0;
|
||||
arg->pixel = 0x80;
|
||||
arg->color = colpixel;
|
||||
u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SET_8PIXEL, arg);
|
||||
}
|
||||
|
||||
/* u8g_IsBBXIntersection() has been moved to u8g_clip.c */
|
||||
#ifdef OBSOLETE_CODE
|
||||
uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
|
||||
{
|
||||
/* new code */
|
||||
u8g_dev_arg_bbx_t arg;
|
||||
arg.x = x;
|
||||
arg.y = y;
|
||||
arg.w = w;
|
||||
arg.h = h;
|
||||
return u8g_is_box_bbx_intersection(&(u8g->current_page), &arg);
|
||||
|
||||
/* old code */
|
||||
//return u8g_IsBBXIntersectionLL(u8g, u8g->dev, x, y, w, h);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
idx: index for the palette entry (0..255)
|
||||
r: value for red (0..255)
|
||||
g: value for green (0..255)
|
||||
b: value for blue (0..255)
|
||||
*/
|
||||
void u8g_SetColorEntry(u8g_t *u8g, uint8_t idx, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
u8g_dev_arg_irgb_t irgb;
|
||||
irgb.idx = idx;
|
||||
irgb.r = r;
|
||||
irgb.g = g;
|
||||
irgb.b = b;
|
||||
u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SET_COLOR_ENTRY, &irgb);
|
||||
}
|
||||
|
||||
void u8g_SetColorIndex(u8g_t *u8g, uint8_t idx)
|
||||
{
|
||||
u8g->arg_pixel.color = idx;
|
||||
/*u8g->color_index = idx; */ /* must be removed */
|
||||
}
|
||||
|
||||
void u8g_SetHiColor(u8g_t *u8g, uint16_t rgb)
|
||||
{
|
||||
u8g->arg_pixel.color = rgb&255;
|
||||
u8g->arg_pixel.hi_color = rgb>>8;
|
||||
/*u8g->color_index = idx; */ /* must be removed */
|
||||
}
|
||||
|
||||
void u8g_SetHiColorByRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
|
||||
r &= ~7;
|
||||
g >>= 2;
|
||||
b >>= 3;
|
||||
u8g->arg_pixel.color = b;
|
||||
u8g->arg_pixel.color |= (g & 7) << 5;
|
||||
u8g->arg_pixel.hi_color = r;
|
||||
u8g->arg_pixel.hi_color |= (g>>3) & 7;
|
||||
|
||||
//u8g_SetHiColor(u8g, U8G_GET_HICOLOR_BY_RGB(r,g,b));
|
||||
}
|
||||
|
||||
void u8g_SetRGB(u8g_t *u8g, uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
if ( u8g->mode == U8G_MODE_R3G3B2 )
|
||||
{
|
||||
r &= 0x0e0;
|
||||
g &= 0x0e0;
|
||||
g >>= 3;
|
||||
b >>= 6;
|
||||
u8g->arg_pixel.color = r | g | b;
|
||||
}
|
||||
else if ( u8g->mode == U8G_MODE_HICOLOR )
|
||||
{
|
||||
u8g_SetHiColorByRGB(u8g, r,g,b);
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g->arg_pixel.color = r;
|
||||
u8g->arg_pixel.hi_color = g;
|
||||
u8g->arg_pixel.blue = b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_GetColorIndex(u8g_t *u8g)
|
||||
{
|
||||
return u8g->arg_pixel.color;
|
||||
}
|
||||
|
||||
uint8_t u8g_GetDefaultForegroundColor(u8g_t *u8g)
|
||||
{
|
||||
uint8_t mode;
|
||||
mode = u8g_GetMode(u8g);
|
||||
if ( mode == U8G_MODE_R3G3B2 )
|
||||
return 255; /* white */
|
||||
else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT )
|
||||
return 3; /* max intensity */
|
||||
/* if ( u8g.getMode() == U8G_MODE_BW ) */
|
||||
return 1; /* pixel on */
|
||||
}
|
||||
|
||||
void u8g_SetDefaultForegroundColor(u8g_t *u8g)
|
||||
{
|
||||
if ( u8g->mode == U8G_MODE_HICOLOR )
|
||||
{
|
||||
u8g->arg_pixel.color = 0x0ff;
|
||||
u8g->arg_pixel.hi_color = 0x0ff;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8g_SetColorIndex(u8g, u8g_GetDefaultForegroundColor(u8g));
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t u8g_GetDefaultBackgroundColor(u8g_t *u8g)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void u8g_SetDefaultBackgroundColor(u8g_t *u8g)
|
||||
{
|
||||
u8g_SetColorIndex(u8g, u8g_GetDefaultBackgroundColor(u8g)); /* pixel on / black */
|
||||
}
|
||||
|
||||
uint8_t u8g_GetDefaultMidColor(u8g_t *u8g)
|
||||
{
|
||||
uint8_t mode;
|
||||
mode = u8g_GetMode(u8g);
|
||||
if ( mode == U8G_MODE_R3G3B2 )
|
||||
return 0x06d; /* gray: 01101101 */
|
||||
else if ( mode == U8G_MODE_GRAY2BIT )
|
||||
return 1; /* low mid intensity */
|
||||
/* if ( u8g.getMode() == U8G_MODE_BW ) */
|
||||
return 1; /* pixel on */
|
||||
}
|
||||
|
||||
void u8g_SetDefaultMidColor(u8g_t *u8g)
|
||||
{
|
||||
u8g_SetColorIndex(u8g, u8g_GetDefaultMidColor(u8g));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_page.c
|
||||
|
||||
page helper functions, only called by the dev handler.
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
/*
|
||||
setup page count structure
|
||||
conditions: page_height <= total_height
|
||||
*/
|
||||
void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height )
|
||||
{
|
||||
p->page_height = page_height;
|
||||
p->total_height = total_height;
|
||||
p->page = 0;
|
||||
u8g_page_First(p);
|
||||
}
|
||||
|
||||
void u8g_page_First(u8g_page_t *p)
|
||||
{
|
||||
p->page_y0 = 0;
|
||||
p->page_y1 = p->page_height;
|
||||
p->page_y1--;
|
||||
p->page = 0;
|
||||
}
|
||||
|
||||
uint8_t u8g_page_Next(u8g_page_t * p)
|
||||
{
|
||||
register u8g_uint_t y1;
|
||||
p->page_y0 += p->page_height;
|
||||
if ( p->page_y0 >= p->total_height )
|
||||
return 0;
|
||||
p->page++;
|
||||
y1 = p->page_y1;
|
||||
y1 += p->page_height;
|
||||
if ( y1 >= p->total_height )
|
||||
{
|
||||
y1 = p->total_height;
|
||||
y1--;
|
||||
}
|
||||
p->page_y1 = y1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,191 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb.c
|
||||
|
||||
common procedures for the page buffer
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
|
||||
void u8g_pb_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
end_ptr += b->width;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
/* the following procedure does not work. why? Can be checked with descpic */
|
||||
/*
|
||||
void u8g_pb_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t cnt = b->width;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
cnt--;
|
||||
} while( cnt != 0 );
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
intersection assumptions:
|
||||
a1 <= a2 is always true
|
||||
*/
|
||||
/*
|
||||
minimized version
|
||||
---1----0 1 b1 <= a2 && b1 > b2
|
||||
-----1--0 1 b2 >= a1 && b1 > b2
|
||||
---1-1--- 1 b1 <= a2 && b2 >= a1
|
||||
*/
|
||||
/*
|
||||
uint8_t u8g_pb8v1_IsYIntersection___Old(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
|
||||
{
|
||||
uint8_t c0, c1, c;
|
||||
c0 = v0 <= b->p.page_y1;
|
||||
c1 = v1 >= b->p.page_y0;
|
||||
c = v0 > v1;
|
||||
if ( c0 && c1 ) return 1;
|
||||
if ( c0 && c ) return 1;
|
||||
if ( c1 && c ) return 1;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
uint8_t u8g_pb_IsYIntersection(u8g_pb_t *pb, u8g_uint_t v0, u8g_uint_t v1)
|
||||
{
|
||||
uint8_t c1, c2, c3, tmp;
|
||||
c1 = v0 <= pb->p.page_y1;
|
||||
c2 = v1 >= pb->p.page_y0;
|
||||
c3 = v0 > v1;
|
||||
/*
|
||||
if ( c1 && c2 )
|
||||
return 1;
|
||||
if ( c1 && c3 )
|
||||
return 1;
|
||||
if ( c2 && c3 )
|
||||
return 1;
|
||||
return 0;
|
||||
*/
|
||||
|
||||
tmp = c1;
|
||||
c1 &= c2;
|
||||
c2 &= c3;
|
||||
c3 &= tmp;
|
||||
c1 |= c2;
|
||||
c1 |= c3;
|
||||
return c1 & 1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_pb_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
|
||||
{
|
||||
uint8_t /*c0, c1, */ c2, c3;
|
||||
/*
|
||||
conditions: b->p.page_y0 < b->p.page_y1
|
||||
there are no restriction on v0 and v1. If v0 > v1, then warp around unsigned is assumed
|
||||
*/
|
||||
/*
|
||||
c0 = v0 < 0;
|
||||
c1 = v1 < 0;
|
||||
*/
|
||||
c2 = v0 > b->width;
|
||||
c3 = v1 > b->width;
|
||||
/*if ( c0 && c1 ) return 0;*/
|
||||
if ( c2 && c3 ) return 0;
|
||||
/*if ( c1 && c2 ) return 0;*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t u8g_pb_IsIntersection(u8g_pb_t *pb, u8g_dev_arg_bbx_t *bbx)
|
||||
{
|
||||
u8g_uint_t tmp;
|
||||
|
||||
tmp = bbx->y;
|
||||
tmp += bbx->h;
|
||||
tmp--;
|
||||
|
||||
if ( u8g_pb_IsYIntersection(pb, bbx->y, tmp) == 0 )
|
||||
return 0;
|
||||
|
||||
/* maybe this one can be skiped... probability is very high to have an intersection, so it would be ok to always return 1 */
|
||||
tmp = bbx->x;
|
||||
tmp += bbx->w;
|
||||
tmp--;
|
||||
|
||||
return u8g_pb_IsXIntersection(pb, bbx->x, tmp);
|
||||
}
|
||||
|
||||
void u8g_pb_GetPageBox(u8g_pb_t *pb, u8g_box_t *box)
|
||||
{
|
||||
box->x0 = 0;
|
||||
box->y0 = pb->p.page_y0;
|
||||
box->x1 = pb->width;
|
||||
box->x1--;
|
||||
box->y1 = pb->p.page_y1;
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_pb_Is8PixelVisible(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
u8g_uint_t v0, v1;
|
||||
v0 = arg_pixel->y;
|
||||
v1 = v0;
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
v1 += 8; /* this is independent from the page height */
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
v0 -= 8;
|
||||
break;
|
||||
}
|
||||
return u8g_pb_IsYIntersection(b, v0, v1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t u8g_pb_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev)
|
||||
{
|
||||
return u8g_WriteSequence(u8g, dev, b->width, b->buf);
|
||||
}
|
||||
|
@ -1,200 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb14v1.c
|
||||
|
||||
14bit height monochrom (1 bit) page buffer,
|
||||
byte has vertical orientation, 7 bits per byte
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb14v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb14v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb14v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb14v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
|
||||
|
||||
void u8g_pb14v1_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
end_ptr += b->width*2;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
/* Obsolete, usually set by the init of the structure */
|
||||
void u8g_pb14v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb14v1_Clear(b);
|
||||
}
|
||||
|
||||
void u8g_pb14v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
if ( y >= 7 )
|
||||
{
|
||||
ptr += b->width;
|
||||
y -= 7;
|
||||
}
|
||||
mask = 1;
|
||||
mask <<= y;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb14v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb14v1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb14v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb14v1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb14v1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb14v1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_pb14v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb14v1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb14v1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb14v1_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb14v1_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,213 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb16h1.c
|
||||
|
||||
2x 8bit height monochrom (1 bit) page buffer
|
||||
byte has horizontal orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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.
|
||||
|
||||
|
||||
total buffer size is limited to 2*256 bytes because of the calculation inside the set pixel procedure
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb16h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb16h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb16h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb16h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
void u8g_pb16h1_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
end_ptr += b->width*2;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void u8g_pb16h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb16h1_Clear(b);
|
||||
}
|
||||
|
||||
|
||||
/* limitation: total buffer must not exceed 2*256 bytes */
|
||||
void u8g_pb16h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
u8g_uint_t tmp;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
if ( y >= 8 )
|
||||
{
|
||||
ptr += b->width;
|
||||
y &= 0x07;
|
||||
}
|
||||
tmp = b->width;
|
||||
tmp >>= 3;
|
||||
tmp *= (uint8_t)y;
|
||||
ptr += tmp;
|
||||
|
||||
mask = 0x080;
|
||||
mask >>= x & 7;
|
||||
x >>= 3;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb16h1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb16h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb16h1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
void u8g_pb16h1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb16h1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb16h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb16h1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb16h1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb16h1_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb16h1_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,208 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb16h2.c
|
||||
|
||||
2 bit per pixel page buffer
|
||||
byte has horizontal orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
void u8g_pb16h2_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
|
||||
/* two bits per pixel, 16 bits height --> 8 pixel --> 4 pixel per byte */
|
||||
end_ptr += b->width;
|
||||
end_ptr += b->width;
|
||||
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
void u8g_pb16h2_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb16h2_Clear(b);
|
||||
}
|
||||
|
||||
static void u8g_pb16h2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index, uint8_t is_or) U8G_NOINLINE;
|
||||
static void u8g_pb16h2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index, uint8_t is_or)
|
||||
{
|
||||
register uint8_t mask;
|
||||
register uint16_t tmp;
|
||||
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
|
||||
tmp = b->width;
|
||||
tmp >>= 2;
|
||||
tmp *= (uint8_t)y;
|
||||
ptr += tmp;
|
||||
|
||||
tmp = x;
|
||||
tmp >>= 2;
|
||||
ptr += tmp;
|
||||
|
||||
tmp = x;
|
||||
tmp &= 3;
|
||||
tmp <<= 1;
|
||||
if ( is_or == 0 )
|
||||
{
|
||||
mask = 3;
|
||||
mask <<= tmp;
|
||||
mask = ~mask;
|
||||
*ptr &= mask;
|
||||
}
|
||||
color_index &= 3;
|
||||
color_index <<= tmp;
|
||||
*ptr |= color_index;
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16h2_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel, uint8_t is_or)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb16h2_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color, is_or);
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16h2_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb16h2_SetPixel(b, arg_pixel, 0);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
void u8g_pb16h2_Or4PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
arg_pixel->color = pixel & 0x0c0;
|
||||
arg_pixel->color >>= 6;
|
||||
u8g_pb16h2_SetPixel(b, arg_pixel, 1);
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 2;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb16h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
{
|
||||
u8g_pb16h2_Set8PixelStd(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb16h2_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg, 0);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_4TPIXEL:
|
||||
u8g_pb16h2_Or4PixelStd(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_TPIXEL:
|
||||
u8g_pb16h2_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg, 1);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_page_First(&(pb->p));
|
||||
u8g_pb16h2_Clear(pb);
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb16h2_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_GRAY2BIT;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,200 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb16v1.c
|
||||
|
||||
16bit height monochrom (1 bit) page buffer
|
||||
byte has vertical orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb16v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb16v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb16v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb16v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
|
||||
|
||||
void u8g_pb16v1_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
end_ptr += b->width*2;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
/* Obsolete, usually set by the init of the structure */
|
||||
void u8g_pb16v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb16v1_Clear(b);
|
||||
}
|
||||
|
||||
void u8g_pb16v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
if ( y >= 8 )
|
||||
{
|
||||
ptr += b->width;
|
||||
y &= 0x07;
|
||||
}
|
||||
mask = 1;
|
||||
mask <<= y;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb16v1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb16v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb16v1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16v1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb16v1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_pb16v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb16v1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb16v1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb16v1_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb16v1_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,172 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb16v2.c
|
||||
|
||||
16 bit height 2 bit per pixel page buffer
|
||||
byte has vertical orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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 "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb16v2_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
|
||||
/* two bits per pixel, 16 bits height --> 8 pixel --> 4 pixel per byte */
|
||||
end_ptr += b->width;
|
||||
end_ptr += b->width;
|
||||
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
void u8g_pb16v2Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb16v2_Clear(b);
|
||||
}
|
||||
|
||||
void u8g_pb16v2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
uint8_t *ptr = b->buf;
|
||||
y -= b->p.page_y0;
|
||||
if ( y >= 4 )
|
||||
{
|
||||
ptr += b->width;
|
||||
}
|
||||
mask = 0x03;
|
||||
y &= 0x03;
|
||||
y <<= 1;
|
||||
mask <<= y;
|
||||
mask ^=0xff;
|
||||
color_index &= 3;
|
||||
color_index <<= y;
|
||||
ptr += x;
|
||||
*ptr &= mask;
|
||||
*ptr |= color_index;
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16v2_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb16v2_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb16v2_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb16v2_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb16v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
{
|
||||
u8g_pb16v2_Set8PixelStd(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb16v2_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb16v2_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb16v2_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_GRAY2BIT;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,208 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb32h1.c
|
||||
|
||||
2x 8bit height monochrom (1 bit) page buffer
|
||||
byte has horizontal orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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.
|
||||
|
||||
|
||||
total buffer size is limited to 2*256 bytes because of the calculation inside the set pixel procedure
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb32h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb32h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb32h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb32h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
void u8g_pb32h1_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
end_ptr += b->width*4;
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void u8g_pb32h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb32h1_Clear(b);
|
||||
}
|
||||
|
||||
|
||||
/* limitation: total buffer must not exceed 2*256 bytes */
|
||||
void u8g_pb32h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
uint16_t tmp;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
tmp = b->width;
|
||||
tmp >>= 3;
|
||||
tmp *= y;
|
||||
ptr += tmp;
|
||||
|
||||
mask = 0x080;
|
||||
mask >>= x & 7;
|
||||
x >>= 3;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb32h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb32h1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb32h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb32h1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
void u8g_pb32h1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb32h1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb32h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb32h1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb32h1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb32h1_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb32h1_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,389 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb8h1.c
|
||||
|
||||
8bit height monochrom (1 bit) page buffer
|
||||
byte has horizontal orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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.
|
||||
|
||||
|
||||
total buffer size is limited to 256 bytes because of the calculation inside the set pixel procedure
|
||||
|
||||
23. Sep 2012: Bug with down procedure, see FPS 1st page --> fixed (bug located in u8g_clip.c)
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __unix__
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
/* NEW_CODE disabled, because the performance increase was too slow and not worth compared */
|
||||
/* to the increase of code size */
|
||||
/* #define NEW_CODE */
|
||||
|
||||
#ifdef __unix__
|
||||
void *u8g_buf_lower_limit;
|
||||
void *u8g_buf_upper_limit;
|
||||
#endif
|
||||
|
||||
void u8g_pb8h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb8h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb8h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb8h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
|
||||
#ifdef NEW_CODE
|
||||
struct u8g_pb_h1_struct
|
||||
{
|
||||
u8g_uint_t x;
|
||||
u8g_uint_t y;
|
||||
uint8_t *ptr;
|
||||
uint8_t mask;
|
||||
uint8_t line_byte_len;
|
||||
uint8_t cnt;
|
||||
};
|
||||
|
||||
static uint8_t u8g_pb8h1_bitmask[8] = { 0x080, 0x040, 0x020, 0x010, 0x008, 0x004, 0x002, 0x001 };
|
||||
|
||||
static void u8g_pb8h1_state_right(struct u8g_pb_h1_struct *s) U8G_NOINLINE;
|
||||
static void u8g_pb8h1_state_right(struct u8g_pb_h1_struct *s)
|
||||
{
|
||||
register u8g_uint_t x;
|
||||
x = s->x;
|
||||
x++;
|
||||
s->x = x;
|
||||
x &= 7;
|
||||
s->mask = u8g_pb8h1_bitmask[x];
|
||||
if ( x == 0 )
|
||||
s->ptr++;
|
||||
}
|
||||
|
||||
static void u8g_pb8h1_state_left(struct u8g_pb_h1_struct *s)
|
||||
{
|
||||
register u8g_uint_t x;
|
||||
x = s->x;
|
||||
x--;
|
||||
s->x = x;
|
||||
x &= 7;
|
||||
s->mask = u8g_pb8h1_bitmask[x];
|
||||
if ( x == 7 )
|
||||
s->ptr--;
|
||||
}
|
||||
|
||||
static void u8g_pb8h1_state_down(struct u8g_pb_h1_struct *s)
|
||||
{
|
||||
s->y++;
|
||||
s->ptr += s->line_byte_len;
|
||||
}
|
||||
|
||||
static void u8g_pb8h1_state_up(struct u8g_pb_h1_struct *s)
|
||||
{
|
||||
s->y--;
|
||||
s->ptr -= s->line_byte_len;
|
||||
}
|
||||
|
||||
static void u8g_pb8h1_state_init(struct u8g_pb_h1_struct *s, u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y) U8G_NOINLINE;
|
||||
static void u8g_pb8h1_state_init(struct u8g_pb_h1_struct *s, u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y)
|
||||
{
|
||||
u8g_uint_t tmp;
|
||||
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
s->x = x;
|
||||
s->y = y;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
|
||||
tmp = b->width;
|
||||
tmp >>= 3;
|
||||
s->line_byte_len = tmp;
|
||||
|
||||
/* assume negative y values, can be down to -7, subtract this from the pointer and add correction of 8 to y */
|
||||
ptr -= tmp*8;
|
||||
y+=8;
|
||||
/* it is important that the result of tmp*y can be 16 bit value also for 8 bit mode */
|
||||
ptr += tmp*y;
|
||||
|
||||
s->mask = u8g_pb8h1_bitmask[x & 7];
|
||||
|
||||
/* assume negative x values (to -7), subtract 8 pixel from the pointer and add 8 to x */
|
||||
ptr--;
|
||||
x += 8;
|
||||
x >>= 3;
|
||||
ptr += x;
|
||||
s->ptr = ptr;
|
||||
}
|
||||
|
||||
static void u8g_pb8h1_state_set_pixel(struct u8g_pb_h1_struct *s, uint8_t color_index) U8G_NOINLINE;
|
||||
static void u8g_pb8h1_state_set_pixel(struct u8g_pb_h1_struct *s, uint8_t color_index)
|
||||
{
|
||||
|
||||
#ifdef __unix__
|
||||
assert( s->ptr >= u8g_buf_lower_limit );
|
||||
assert( s->ptr < u8g_buf_upper_limit );
|
||||
#endif
|
||||
|
||||
if ( color_index )
|
||||
{
|
||||
*s->ptr |= s->mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8_t mask = s->mask;
|
||||
mask ^=0xff;
|
||||
*s->ptr &= mask;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void u8g_pb8h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb_Clear(b);
|
||||
}
|
||||
|
||||
/* limitation: total buffer must not exceed 256 bytes */
|
||||
void u8g_pb8h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
#ifdef NEW_CODE
|
||||
struct u8g_pb_h1_struct s;
|
||||
u8g_pb8h1_state_init(&s, b, x, y);
|
||||
u8g_pb8h1_state_set_pixel(&s, color_index);
|
||||
|
||||
// u8g_pb8h1_state_up(&s);
|
||||
// if ( s.y > b->p.page_y1 )
|
||||
// return;
|
||||
// if ( s.x > b->width )
|
||||
// return;
|
||||
// u8g_pb8h1_state_set_pixel(&s, color_index);
|
||||
#else
|
||||
register uint8_t mask;
|
||||
u8g_uint_t tmp;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
tmp = b->width;
|
||||
tmp >>= 3;
|
||||
tmp *= (uint8_t)y;
|
||||
ptr += tmp;
|
||||
|
||||
mask = 0x080;
|
||||
mask >>= x & 7;
|
||||
x >>= 3;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb8h1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb8h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb8h1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
void u8g_pb8h1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
#ifdef NEW_CODE
|
||||
static void u8g_pb8h1_Set8PixelState(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
struct u8g_pb_h1_struct s;
|
||||
uint8_t cnt;
|
||||
u8g_pb8h1_state_init(&s, b, arg_pixel->x, arg_pixel->y);
|
||||
cnt = 8;
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0:
|
||||
do
|
||||
{
|
||||
if ( s.x < b->width )
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
|
||||
u8g_pb8h1_state_right(&s);
|
||||
pixel <<= 1;
|
||||
cnt--;
|
||||
} while( cnt > 0 && pixel != 0 );
|
||||
break;
|
||||
case 1:
|
||||
do
|
||||
{
|
||||
if ( s.y >= b->p.page_y0 )
|
||||
if ( s.y <= b->p.page_y1 )
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
|
||||
u8g_pb8h1_state_down(&s);
|
||||
pixel <<= 1;
|
||||
cnt--;
|
||||
} while( cnt > 0 && pixel != 0 );
|
||||
break;
|
||||
case 2:
|
||||
do
|
||||
{
|
||||
if ( s.x < b->width )
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
|
||||
u8g_pb8h1_state_left(&s);
|
||||
pixel <<= 1;
|
||||
cnt--;
|
||||
} while( cnt > 0 && pixel != 0 );
|
||||
break;
|
||||
case 3:
|
||||
do
|
||||
{
|
||||
if ( s.y >= b->p.page_y0 )
|
||||
if ( s.y <= b->p.page_y1 )
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1_state_set_pixel(&s, arg_pixel->color);
|
||||
u8g_pb8h1_state_up(&s);
|
||||
pixel <<= 1;
|
||||
cnt--;
|
||||
} while( cnt > 0 && pixel != 0 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
#ifdef NEW_CODE
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb8h1_Set8PixelState(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
#else
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb8h1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
#endif
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb8h1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,194 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb8h1f.c
|
||||
|
||||
8bit height monochrom (1 bit) page buffer
|
||||
byte has horizontal orientation, same as u8g_pb8h1, but byte is flipped
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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.
|
||||
|
||||
|
||||
total buffer size is limited to 256 bytes because of the calculation inside the set pixel procedure
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb8h1f_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb8h1f_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb8h1f_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb8h1f_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
uint8_t u8g_dev_pb8h1f_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
|
||||
|
||||
|
||||
void u8g_pb8h1f_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb_Clear(b);
|
||||
}
|
||||
|
||||
/* limitation: total buffer must not exceed 256 bytes, 20 nov 2012: extended to >256 bytes */
|
||||
void u8g_pb8h1f_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
/*register uint8_t mask, tmp;*/
|
||||
register uint8_t mask;
|
||||
register u8g_uint_t tmp;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
tmp = b->width >> 3;
|
||||
tmp *= (uint8_t)y;
|
||||
ptr += tmp;
|
||||
|
||||
mask = 1;
|
||||
mask <<= x & 7;
|
||||
x >>= 3;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h1f_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb8h1f_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb8h1f_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb8h1f_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
void u8g_pb8h1f_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h1f_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb8h1f_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb8h1f_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb8h1f_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,167 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb8h2.c
|
||||
|
||||
8bit height 2 bit per pixel page buffer
|
||||
byte has horizontal orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
void u8g_pb8h2_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb_Clear(b);
|
||||
}
|
||||
|
||||
static void u8g_pb8h2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
static void u8g_pb8h2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
register uint16_t tmp;
|
||||
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
|
||||
tmp = b->width;
|
||||
tmp >>= 2;
|
||||
tmp *= (uint8_t)y;
|
||||
ptr += tmp;
|
||||
|
||||
tmp = x;
|
||||
tmp >>= 2;
|
||||
ptr += tmp;
|
||||
|
||||
tmp = x;
|
||||
tmp &= 3;
|
||||
tmp <<= 1;
|
||||
mask = 3;
|
||||
mask <<= tmp;
|
||||
mask = ~mask;
|
||||
color_index &= 3;
|
||||
color_index <<= tmp;
|
||||
|
||||
*ptr &= mask;
|
||||
*ptr |= color_index;
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h2_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb8h2_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h2_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb8h2_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb8h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
{
|
||||
u8g_pb8h2_Set8PixelStd(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
}
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb8h2_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_GRAY2BIT;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,185 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb8h8.c
|
||||
|
||||
8 lines per page, horizontal, 8 bits per pixel
|
||||
(22 May 2013: might also support any number of lines --> needs to be checked)
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2012, 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.
|
||||
|
||||
|
||||
struct _u8g_pb_t
|
||||
{
|
||||
u8g_page_t p;
|
||||
u8g_uint_t width;
|
||||
void *buf;
|
||||
};
|
||||
typedef struct _u8g_pb_t u8g_pb_t;
|
||||
|
||||
|
||||
uint8_t u8g_index_color_8h8_buf[WIDTH*PAGE_HEIGHT] U8G_NOCOMMON ;
|
||||
u8g_pb_t u8g_index_color_8h8_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0}, WIDTH, u8g_index_color_8h8_buff};
|
||||
u8g_dev_t name = { dev_fn, &u8g_index_color_8h8_pb, com_fn }
|
||||
|
||||
*/
|
||||
|
||||
#include "u8g.h"
|
||||
|
||||
/*
|
||||
#define WIDTH_BITS 7
|
||||
#define WIDTH (1<<WIDTH_BITS)
|
||||
#define PAGE_HEIGHT_BITS 3
|
||||
#define PAGE_HEIGHT (1<<PAGE_HEIGHT_BITS)
|
||||
*/
|
||||
|
||||
void u8g_pb8h8_Clear(u8g_pb_t *b)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)b->buf;
|
||||
uint8_t *end_ptr = ptr;
|
||||
uint8_t cnt = b->p.page_height;
|
||||
end_ptr += b->width*cnt;
|
||||
/*
|
||||
do
|
||||
{
|
||||
end_ptr += b->width;
|
||||
cnt--;
|
||||
} while( cnt > 0 );
|
||||
*/
|
||||
do
|
||||
{
|
||||
*ptr++ = 0;
|
||||
} while( ptr != end_ptr );
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h8_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb8h8_Clear(b);
|
||||
}
|
||||
|
||||
static void u8g_pb8h8_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
uint16_t tmp;
|
||||
uint8_t *ptr = b->buf;
|
||||
y -= b->p.page_y0;
|
||||
tmp = y;
|
||||
tmp *= b->width;
|
||||
tmp += x;
|
||||
ptr += tmp;
|
||||
*ptr = color_index;
|
||||
}
|
||||
|
||||
void u8g_pb8h8_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb8h8_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8h8_Set8Pixel(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8h8_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
uint8_t u8g_dev_pb8h8_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb8h8_Set8Pixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb8h8_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb8h8_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb8h8_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_R3G3B2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,184 +0,0 @@
|
||||
/*
|
||||
|
||||
u8g_pb8v1.c
|
||||
|
||||
8bit height monochrom (1 bit) page buffer
|
||||
byte has vertical orientation
|
||||
|
||||
Universal 8bit Graphics Library
|
||||
|
||||
Copyright (c) 2011, 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 "u8g.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void u8g_pb8v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
|
||||
void u8g_pb8v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
|
||||
void u8g_pb8v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
|
||||
void u8g_pb8v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
|
||||
|
||||
/* Obsolete, usually set by the init of the structure */
|
||||
void u8g_pb8v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
|
||||
{
|
||||
b->buf = buf;
|
||||
b->width = width;
|
||||
u8g_pb_Clear(b);
|
||||
}
|
||||
|
||||
void u8g_pb8v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
|
||||
{
|
||||
register uint8_t mask;
|
||||
uint8_t *ptr = b->buf;
|
||||
|
||||
y -= b->p.page_y0;
|
||||
mask = 1;
|
||||
y &= 0x07;
|
||||
mask <<= y;
|
||||
ptr += x;
|
||||
if ( color_index )
|
||||
{
|
||||
*ptr |= mask;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask ^=0xff;
|
||||
*ptr &= mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
|
||||
{
|
||||
if ( arg_pixel->y < b->p.page_y0 )
|
||||
return;
|
||||
if ( arg_pixel->y > b->p.page_y1 )
|
||||
return;
|
||||
if ( arg_pixel->x >= b->width )
|
||||
return;
|
||||
u8g_pb8v1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
|
||||
}
|
||||
|
||||
void u8g_pb8v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
{
|
||||
u8g_pb8v1_SetPixel(b, arg_pixel);
|
||||
}
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: arg_pixel->x++; break;
|
||||
case 1: arg_pixel->y++; break;
|
||||
case 2: arg_pixel->x--; break;
|
||||
case 3: arg_pixel->y--; break;
|
||||
}
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
}
|
||||
|
||||
|
||||
void u8g_pb8v1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
|
||||
{
|
||||
register uint8_t pixel = arg_pixel->pixel;
|
||||
u8g_uint_t dx = 0;
|
||||
u8g_uint_t dy = 0;
|
||||
|
||||
switch( arg_pixel->dir )
|
||||
{
|
||||
case 0: dx++; break;
|
||||
case 1: dy++; break;
|
||||
case 2: dx--; break;
|
||||
case 3: dy--; break;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 128 )
|
||||
u8g_pb8v1_SetPixel(b, arg_pixel);
|
||||
arg_pixel->x += dx;
|
||||
arg_pixel->y += dy;
|
||||
pixel <<= 1;
|
||||
} while( pixel != 0 );
|
||||
|
||||
}
|
||||
|
||||
uint8_t u8g_dev_pb8v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
|
||||
{
|
||||
u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
|
||||
switch(msg)
|
||||
{
|
||||
case U8G_DEV_MSG_SET_8PIXEL:
|
||||
if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
|
||||
u8g_pb8v1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_PIXEL:
|
||||
u8g_pb8v1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_INIT:
|
||||
break;
|
||||
case U8G_DEV_MSG_STOP:
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_FIRST:
|
||||
u8g_pb_Clear(pb);
|
||||
u8g_page_First(&(pb->p));
|
||||
break;
|
||||
case U8G_DEV_MSG_PAGE_NEXT:
|
||||
if ( u8g_page_Next(&(pb->p)) == 0 )
|
||||
return 0;
|
||||
u8g_pb_Clear(pb);
|
||||
break;
|
||||
#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
|
||||
case U8G_DEV_MSG_IS_BBX_INTERSECTION:
|
||||
return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
|
||||
#endif
|
||||
case U8G_DEV_MSG_GET_PAGE_BOX:
|
||||
u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_WIDTH:
|
||||
*((u8g_uint_t *)arg) = pb->width;
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_HEIGHT:
|
||||
*((u8g_uint_t *)arg) = pb->p.total_height;
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_COLOR_ENTRY:
|
||||
break;
|
||||
case U8G_DEV_MSG_SET_XY_CB:
|
||||
break;
|
||||
case U8G_DEV_MSG_GET_MODE:
|
||||
return U8G_MODE_BW;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user