Skip to content

Commit

Permalink
5x7 example for the LM234 display, issue #1492
Browse files Browse the repository at this point in the history
  • Loading branch information
olikraus committed Jul 30, 2021
1 parent 4054dfd commit 1c4e166
Show file tree
Hide file tree
Showing 7 changed files with 683 additions and 5 deletions.
12 changes: 8 additions & 4 deletions csrc/u8x8_d_hd44102.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
u8x8_d_hd44102.c
Support for HD44102 and T7932 controller
Support for HD44102 and T7932 controller (https://github.com/olikraus/u8g2/issues/1492)
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
Expand Down Expand Up @@ -220,6 +220,8 @@ uint8_t u8x8_d_t7932_150x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *ar
case U8X8_MSG_DISPLAY_DRAW_TILE:
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
cnt = ((u8x8_tile_t *)arg_ptr)->cnt;
x*=8;
cnt*=8;

do
{
Expand Down Expand Up @@ -308,9 +310,11 @@ uint8_t u8x8_d_hd44102_100x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
// case U8X8_MSG_DISPLAY_SET_CONTRAST:
// break;
case U8X8_MSG_DISPLAY_DRAW_TILE:
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
x = ((u8x8_tile_t *)arg_ptr)->x_pos;
cnt = ((u8x8_tile_t *)arg_ptr)->cnt;
page = ((u8x8_tile_t *)arg_ptr)->y_pos;
x*=8;
cnt*=8;
if ( page < 4 )
{
do
Expand All @@ -320,7 +324,7 @@ uint8_t u8x8_d_hd44102_100x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
cnt,
page,
x,
7, 0, 2, 7);
7, 0, 1, 7);
arg_int--;
x += cnt;
} while (arg_int > 0);
Expand All @@ -334,7 +338,7 @@ uint8_t u8x8_d_hd44102_100x64(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *
cnt,
page-4,
x,
7, 1, 3, 7);
7, 2, 3, 7);
arg_int--;
x += cnt;
} while (arg_int > 0);
Expand Down
510 changes: 510 additions & 0 deletions sys/arduino/u8g2_page_buffer/5x7/5x7.ino

Large diffs are not rendered by default.

147 changes: 147 additions & 0 deletions sys/arduino/u8g2_page_buffer/5x7/Makefile.184.uno
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#
# Makefile.180 for Arduino/AVR
#
# Note:
# Display list make database: make -p -f/dev/null | less


# Install path of the arduino software. Requires a '/' at the end.
ARDUINO_PATH:=/home/kraus/prg/arduino-1.8.4/

# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/avr/boards.txt
# Some examples:
# BOARD DESCRIPTION
# uno Arduino Uno
# atmega328 Arduino Duemilanove or Nano w/ ATmega328
# diecimila Arduino Diecimila, Duemilanove, or Nano w/ ATmega168
# mega Arduino Mega
# mega2560 Arduino Mega2560
# mini Arduino Mini
# lilypad328 LilyPad Arduino w/ ATmega328
BOARD:=uno

# The unix device where we can reach the arduino board
# Uno: /dev/ttyACM0
# Duemilanove: /dev/ttyUSB0
AVRDUDE_PORT:=/dev/ttyACM0



SRC_DIRS=$(ARDUINO_PATH)hardware/arduino/avr/cores/arduino/
SRC_DIRS+=$(ARDUINO_PATH)hardware/arduino/avr/libraries/SPI/src/
SRC_DIRS+=$(ARDUINO_PATH)hardware/arduino/avr/libraries/SPI/src/utility/
SRC_DIRS+=$(ARDUINO_PATH)hardware/arduino/avr/libraries/Wire/src/
SRC_DIRS+=$(ARDUINO_PATH)hardware/arduino/avr/libraries/Wire/src/utility/
SRC_DIRS+=../../../../csrc/
SRC_DIRS+=../../../../cppsrc/

#=== suffixes ===
.SUFFIXES: .elf .hex .ino

#=== identify user files ===
INOSRC:=$(shell ls *.ino)
TARGETNAME=$(basename $(INOSRC))

#=== internal names ===
LIBNAME:=$(TARGETNAME).a
ELFNAME:=$(TARGETNAME).elf
HEXNAME:=$(TARGETNAME).hex
BINNAME:=$(TARGETNAME).bin
DISNAME:=$(TARGETNAME).dis
MAPNAME:=$(TARGETNAME).map


#=== replace standard tools ===
CC:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-gcc
CXX:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-g++
AR:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-gcc-ar
OBJCOPY:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-objcopy
OBJDUMP:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-objdump
SIZE:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-size

AVRDUDE = $(ARDUINO_PATH)hardware/tools/avr/bin/avrdude


#=== get values from boards.txt ===
BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/avr/boards.txt

# get the MCU value from the $(BOARD).build.mcu variable. For the atmega328 board this is atmega328p
MCU:=$(shell sed -n -e "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_TXT))
# get the F_CPU value from the $(BOARD).build.f_cpu variable. For the atmega328 board this is 16000000
F_CPU:=$(shell sed -n -e "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_TXT))
# get variant subfolder
VARIANT:=$(shell sed -n -e "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_TXT))
UPLOAD_SPEED:=$(shell sed -n -e "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_TXT))
# get the AVRDUDE_PROGRAMMER value from the $(BOARD).upload.protocol variable. For the atmega328 board this is stk500
UPLOAD_PROTOCOL:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT))
# use stk500v1, because stk500 will default to stk500v2
#UPLOAD_PROTOCOL:=stk500v1

AVRDUDE_FLAGS = -V -F
AVRDUDE_FLAGS += -C $(ARDUINO_PATH)/hardware/tools/avr/etc/avrdude.conf
AVRDUDE_FLAGS += -p $(MCU)
AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
AVRDUDE_FLAGS += -c $(UPLOAD_PROTOCOL)
AVRDUDE_FLAGS += -b $(UPLOAD_SPEED)
AVRDUDE_FLAGS += -U flash:w:$(HEXNAME)

#=== get all include dirs ===
INC_DIRS:=. $(SRC_DIRS) $(ARDUINO_PATH)hardware/arduino/avr/variants/$(VARIANT)
INC_OPTS:=$(addprefix -I,$(INC_DIRS))

#=== get all source files ===
CSRC:=$(shell ls $(addsuffix *.c,$(SRC_DIRS)) 2>/dev/null)
CPPSRC:=$(shell ls $(addsuffix *.cpp,$(SRC_DIRS)) 2>/dev/null)

#=== get all obj files ===
COBJ:=$(CSRC:.c=.o)
CPPOBJ:=$(CPPSRC:.cpp=.o)
OBJ:=$(COBJ) $(CPPOBJ) $(TARGETNAME).o


#=== options ===

COMMON_FLAGS = -g -Os -DF_CPU=$(F_CPU) -mmcu=$(MCU)
COMMON_FLAGS +=-DARDUINO=10800 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR
COMMON_FLAGS +=-ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects
COMMON_FLAGS +=$(INC_OPTS)
CFLAGS:=$(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes -Wall -Wextra
CXXFLAGS:=$(COMMON_FLAGS) -std=gnu++11 -fpermissive -fno-exceptions
LDFLAGS:=-g -Os -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=$(MCU) -Wl,--Map=$(MAPNAME)
LDLIBS:=-lm

all: $(HEXNAME) $(DISNAME)
$(SIZE) $(ELFNAME)

.PHONY: debug
debug:
@echo $(MCU) $(F_CPU) $(VARIANT) $(UPLOAD_SPEED) $(UPLOAD_PROTOCOL)
@echo $(SRC_DIRS)
@echo $(CSRC)
@echo $(CPPSRC)
@echo $(INC_OPTS)

.PHONY: clean
clean:
$(RM) $(OBJ) $(HEXNAME) $(ELFNAME) $(LIBNAME) $(DISNAME) $(MAPNAME) $(BINNAME)

.PHONY: upload
upload: $(HEXNAME)
stty -F $(AVRDUDE_PORT) hupcl
$(AVRDUDE) $(AVRDUDE_FLAGS)

# implicit rules
.ino.cpp:
@cp $< $@

.elf.hex:
@$(OBJCOPY) -O ihex -R .eeprom $< $@

# explicit rules
$(ELFNAME): $(LIBNAME)($(OBJ))
$(LINK.o) $(LFLAGS) $(LIBNAME) $(LDLIBS) -o $@

$(DISNAME): $(ELFNAME)
$(OBJDUMP) -D -S $< > $@


8 changes: 8 additions & 0 deletions tools/font/bdfconv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ greek: bdfconv
10x20greek: bdfconv
./bdfconv -f 1 -v -m '32-127,$$370-$$3ff' ../bdf/10x20.bdf -n 10x20_greek -o 10x20_greek.c -d ../bdf/7x13.bdf

5x7: bdfconv
./bdfconv -b 4 -f 1 -a -v -m '32-255' ../bdf/5x7.bdf -n 5x7lcd -o 5x7lcd.c -d ../bdf/7x13.bdf

ti83: bdfconv
-../otf2bdf/otf2bdf -n -p 5 -o ../bdf/ti83.bdf ../ttf/ti83.ttf
./bdfconv -b 4 -f 1 -a -v -m '32-65000' ../bdf/ti83.bdf -n u8g2_ti83_5x7 -o ti83.c -d ../bdf/7x13.bdf


polish: bdfconv
./bdfconv -f 1 -v -m '32-127,$$104-$$107,$$118-$$119,$$141-$$144,$$15a-$$15b,$$179-$$17c,$$d3,$$f3' ../bdf/unifont.bdf -n unifont_polish -o unifont_polish.c -d ../bdf/7x13.bdf

Expand Down
8 changes: 8 additions & 0 deletions tools/font/bdfconv/bdf_font.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,14 @@ void bf_copy_bbx_and_update_shift(bf_t *bf, bbx_t *target_bbx, bg_t *bg)
if ( target_bbx->w < bg->dwidth_x )
target_bbx->w = bg->dwidth_x;
}
else if ( bf->bbx_mode == BDF_BBX_MODE_5X7 ) // mode 4 (5x7 displays)
{
*target_bbx = bf->max;
target_bbx->x = 0;
if ( bg->bbx.x < 0 )
bg->shift_x = bg->bbx.x;
target_bbx->w = 5;
}
else if ( bf->bbx_mode == BDF_BBX_MODE_M8 )
{
/* old
Expand Down
1 change: 1 addition & 0 deletions tools/font/bdfconv/bdf_font.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define BDF_BBX_MODE_HEIGHT 1
#define BDF_BBX_MODE_MAX 2
#define BDF_BBX_MODE_M8 3
#define BDF_BBX_MODE_5X7 4

struct _bdf_font_struct
{
Expand Down
2 changes: 1 addition & 1 deletion tools/font/bdfconv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void help(void)
printf("bdfconv [options] filename\n");
printf("-h Display this help\n");
printf("-v Print log messages\n");
printf("-b <n> Font build mode, 0: proportional, 1: common height, 2: monospace, 3: multiple of 8\n");
printf("-b <n> Font build mode, 0: proportional, 1: common height, 2: monospace, 3: multiple of 8, 4: 5x7 mode\n");
printf("-f <n> Font format, 0: ucglib font, 1: u8g2 font, 2: u8g2 uncompressed 8x8 font (enforces -b 3)\n");
printf("-m 'map' Unicode ASCII mapping\n");
printf("-M 'mapfile' Read Unicode ASCII mapping from file 'mapname'\n");
Expand Down

0 comments on commit 1c4e166

Please sign in to comment.