Skip to content

Commit

Permalink
tests, cffs, towards 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
olikraus committed Nov 3, 2013
1 parent d3b3d3f commit e40e55d
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 5 deletions.
4 changes: 3 additions & 1 deletion arduino/u8g/Combo/Combo.pde
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
uint8_t uiKeyUpPin = 7;
uint8_t uiKeyDownPin = 3;
uint8_t uiKeySelectPin = 2;
uint8_t uiKeySelectPin2 = 8;

uint8_t select_color = 0;
uint8_t select_priority = 0;
Expand Down Expand Up @@ -152,7 +153,7 @@ M2_LIST(list) = {
&el_cancel, &el_ok
};
M2_GRIDLIST(list_element, "c2",list);
M2tk m2(&list_element, m2_es_arduino, m2_eh_2bs, m2_gh_u8g_ffs);
M2tk m2(&list_element, m2_es_arduino, m2_eh_4bs, m2_gh_u8g_ffs);

// U8glib draw procedure: Just call the M2tklib draw procedure
void draw(void) {
Expand All @@ -169,6 +170,7 @@ void setup() {

// Setup keys
m2.setPin(M2_KEY_SELECT, uiKeySelectPin);
m2.setPin(M2_KEY_SELECT2, uiKeySelectPin2);
m2.setPin(M2_KEY_NEXT, uiKeyDownPin);
m2.setPin(M2_KEY_PREV, uiKeyUpPin);
}
Expand Down
287 changes: 287 additions & 0 deletions arduino/u8g/Combo/Makefile.103.uno
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@

#
# Arduino-1.0 Makefile
#
# written by olikraus@gmail.com
#
# Features:
# - boards.txt is used to derive parameters
# - All intermediate files are put into a separate directory (TMPDIRNAME)
# - Simple use: Copy Makefile into the same directory of the .pde file
#
# Limitations:
# - requires UNIX environment
# - TMPDIRNAME must be subdirectory of the current directory.
#
# Targets
# all build everything
# upload build and upload to arduino
# clean remove all temporary files (includes final hex file)
#
# History
# 001 28 Apr 2010 first release
# 002 05 Oct 2010 added 'uno'
# 003 06 Dec 2011 arduino 1.0
# 004 11 Feb 2012 u8glib
# 005 05 Apr 2012 m2tklib
#

#=== user configuration ===
# All ...PATH variables must have a '/' at the end

# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/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
# mini Arduino Mini
# lilypad328 LilyPad Arduino w/ ATmega328
BOARD:=uno

# additional definitions
#DEFS:=-DARDUINO=100


U8G_PATH:=$(shell cd ../../../../../u8g/u8glib && pwd)/csrc/
U8G_CPP_PATH:=$(shell cd ../../../../../u8g/u8glib && pwd)/cppsrc/
U8G_FONT_PATH:=$(shell cd ../../../../../u8g/u8glib && pwd)/sfntsrc/

M2TKLIB_PATH:=$(shell cd ../../.. && pwd)/src/
M2TKCPP_PATH:=$(shell cd ../../.. && pwd)/cpp/
M2DEV_PATH:=$(shell cd ../../.. && pwd)/dev/u8glib/
M2DEV2_PATH:=$(shell cd ../../.. && pwd)/dev/arduino/


# The location where the avr tools (e.g. avr-gcc) are located. Requires a '/' at the end.
# Can be empty if all tools are accessable through the search path
AVR_TOOLS_PATH:=/usr/bin/

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

# Install path for avrdude. Requires a '/' at the end. Can be empty if avrdude is in the search path.
AVRDUDE_PATH:=$(ARDUINO_PATH)hardware/tools/

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

# List of all libaries which should be included.
EXTRA_DIRS=$(ARDUINO_PATH)libraries/LiquidCrystal/
#EXTRA_DIRS+=$(ARDUINO_PATH)libraries/.../

#=== fetch parameter from boards.txt processor parameter ===
# the basic idea is to get most of the information from boards.txt

BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/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))


# avrdude
# get the AVRDUDE_UPLOAD_RATE value from the $(BOARD).upload.speed variable. For the atmega328 board this is 57600
AVRDUDE_UPLOAD_RATE:=$(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
AVRDUDE_PROGRAMMER:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT))
# use stk500v1, because stk500 will default to stk500v2
#AVRDUDE_PROGRAMMER:=stk500v1

#=== identify user files ===
PDESRC:=$(shell ls *.pde)
TARGETNAME=$(basename $(PDESRC))

CDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS))
CDIRS:=*.c utility/*.c $(U8G_PATH)*.c $(U8G_FONT_PATH)*.c $(M2TKLIB_PATH)*.c $(M2DEV_PATH)*.c $(M2DEV2_PATH)*.c $(addsuffix *.c,$(CDIRS)) $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.c
CSRC:=$(shell ls $(CDIRS) 2>/dev/null)

CCSRC:=$(shell ls *.cc 2>/dev/null)

CPPDIRS:=$(EXTRA_DIRS) $(addsuffix utility/,$(EXTRA_DIRS))
CPPDIRS:=*.cpp utility/*.cpp $(addsuffix *.cpp,$(CPPDIRS)) $(U8G_CPP_PATH)/*.cpp $(M2TKCPP_PATH)/*.cpp $(ARDUINO_PATH)hardware/arduino/cores/arduino/*.cpp
CPPSRC:=$(shell ls $(CPPDIRS) 2>/dev/null)

#=== build internal variables ===

# the name of the subdirectory where everything is stored
TMPDIRNAME:=tmp
TMPDIRPATH:=$(TMPDIRNAME)/

AVRTOOLSPATH:=$(AVR_TOOLS_PATH)

OBJCOPY:=$(AVRTOOLSPATH)avr-objcopy
OBJDUMP:=$(AVRTOOLSPATH)avr-objdump
SIZE:=$(AVRTOOLSPATH)avr-size

CPPSRC:=$(addprefix $(TMPDIRPATH),$(PDESRC:.pde=.cpp)) $(CPPSRC)

COBJ:=$(CSRC:.c=.o)
CCOBJ:=$(CCSRC:.cc=.o)
CPPOBJ:=$(CPPSRC:.cpp=.o)

OBJFILES:=$(COBJ) $(CCOBJ) $(CPPOBJ)
DIRS:= $(dir $(OBJFILES))

DEPFILES:=$(OBJFILES:.o=.d)
# assembler files from avr-gcc -S
ASSFILES:=$(OBJFILES:.o=.s)
# disassembled object files with avr-objdump -S
DISFILES:=$(OBJFILES:.o=.dis)


LIBNAME:=$(TMPDIRPATH)$(TARGETNAME).a
ELFNAME:=$(TMPDIRPATH)$(TARGETNAME).elf
HEXNAME:=$(TMPDIRPATH)$(TARGETNAME).hex

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

AVRDUDE = $(AVRDUDE_PATH)avrdude

#=== predefined variable override ===
# use "make -p -f/dev/null" to see the default rules and definitions

# Build C and C++ flags. Include path information must be placed here
COMMON_FLAGS = -DF_CPU=$(F_CPU) -mmcu=$(MCU) $(DEFS) -DARDUINO=100
# COMMON_FLAGS += -gdwarf-2
COMMON_FLAGS += -Os
COMMON_FLAGS += -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
COMMON_FLAGS += -I. -I$(M2TKLIB_PATH) -I$(M2DEV_PATH) -I$(M2TKCPP_PATH)
COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/cores/arduino
COMMON_FLAGS += -I$(ARDUINO_PATH)hardware/arduino/variants/$(VARIANT)
COMMON_FLAGS += -I. -I$(U8G_PATH) -I$(U8G_CPP_PATH)
COMMON_FLAGS += $(addprefix -I,$(EXTRA_DIRS))
COMMON_FLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections
COMMON_FLAGS += -Wl,--Map=output.map
COMMON_FLAGS += -Wl,--relax
COMMON_FLAGS += -mcall-prologues

CFLAGS = $(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes
CXXFLAGS = $(COMMON_FLAGS)

# Replace standard build tools by avr tools
CC = $(AVRTOOLSPATH)avr-gcc
CXX = $(AVRTOOLSPATH)avr-g++
AR = @$(AVRTOOLSPATH)avr-ar


# "rm" must be able to delete a directory tree
RM = rm -rf

#=== rules ===

# add rules for the C/C++ files where the .o file is placed in the TMPDIRPATH
# reuse existing variables as far as possible

$(TMPDIRPATH)%.o: %.c
@echo compile $<
@$(COMPILE.c) $(OUTPUT_OPTION) $<

$(TMPDIRPATH)%.o: %.cc
@echo compile $<
@$(COMPILE.cc) $(OUTPUT_OPTION) $<

$(TMPDIRPATH)%.o: %.cpp
@echo compile $<
@$(COMPILE.cpp) $(OUTPUT_OPTION) $<

$(TMPDIRPATH)%.s: %.c
@$(COMPILE.c) $(OUTPUT_OPTION) -S $<

$(TMPDIRPATH)%.s: %.cc
@$(COMPILE.cc) $(OUTPUT_OPTION) -S $<

$(TMPDIRPATH)%.s: %.cpp
@$(COMPILE.cpp) $(OUTPUT_OPTION) -S $<

$(TMPDIRPATH)%.dis: $(TMPDIRPATH)%.o
@$(OBJDUMP) -S $< > $@

.SUFFIXES: .elf .hex .pde

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

$(TMPDIRPATH)%.cpp: %.pde
@cat $(ARDUINO_PATH)hardware/arduino/cores/arduino/main.cpp > $@
@cat $< >> $@
@echo >> $@
@echo 'extern "C" void __cxa_pure_virtual() { while (1); }' >> $@


.PHONY: all
all: tmpdir $(HEXNAME) assemblersource showsize
ls -al $(HEXNAME) $(ELFNAME)

$(ELFNAME): $(LIBNAME)($(addprefix $(TMPDIRPATH),$(OBJFILES)))
$(LINK.o) $(COMMON_FLAGS) $(LIBNAME) $(LOADLIBES) $(LDLIBS) -o $@

$(LIBNAME)(): $(addprefix $(TMPDIRPATH),$(OBJFILES))

#=== create temp directory ===
# not really required, because it will be also created during the dependency handling
.PHONY: tmpdir
tmpdir:
@test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH)

#=== create assembler files for each C/C++ file ===
.PHONY: assemblersource
assemblersource: $(addprefix $(TMPDIRPATH),$(ASSFILES)) $(addprefix $(TMPDIRPATH),$(DISFILES))


#=== show the section sizes of the ELF file ===
.PHONY: showsize
showsize: $(ELFNAME)
$(SIZE) $<

#=== clean up target ===
# this is simple: the TMPDIRPATH is removed
.PHONY: clean
clean:
$(RM) $(TMPDIRPATH)

# Program the device.
# step 1: reset the arduino board with the stty command
# step 2: user avrdude to upload the software
.PHONY: upload
upload: $(HEXNAME)
stty -F $(AVRDUDE_PORT) hupcl
$(AVRDUDE) $(AVRDUDE_FLAGS)


# === dependency handling ===
# From the gnu make manual (section 4.14, Generating Prerequisites Automatically)
# Additionally (because this will be the first executed rule) TMPDIRPATH is created here.
# Instead of "sed" the "echo" command is used
# cd $(TMPDIRPATH); mkdir -p $(DIRS) 2> /dev/null; cd ..
DEPACTION=test -d $(TMPDIRPATH) || mkdir $(TMPDIRPATH);\
mkdir -p $(addprefix $(TMPDIRPATH),$(DIRS));\
set -e; echo -n $@ $(dir $@) > $@; $(CC) -MM $(COMMON_FLAGS) $< >> $@


$(TMPDIRPATH)%.d: %.c
@$(DEPACTION)

$(TMPDIRPATH)%.d: %.cc
@$(DEPACTION)

$(TMPDIRPATH)%.d: %.cpp
@$(DEPACTION)

# Include dependency files. If a .d file is missing, a warning is created and the .d file is created
# This warning is not a problem (gnu make manual, section 3.3 Including Other Makefiles)
-include $(addprefix $(TMPDIRPATH),$(DEPFILES))


2 changes: 1 addition & 1 deletion arduino/u8g/XBM/XBM.pde
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGS102 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGM132 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_DOGM128 u8g(13, 11, 10, 9); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
Expand Down
5 changes: 4 additions & 1 deletion sdl/m2ghsdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ void m2_sdl_init(void)

m2_sdl_color = SDL_MapRGB( m2_sdl_screen->format, 100, 255, 0 );

/*
m2_sdl_set_pixel(0,0);
m2_sdl_set_pixel(1,1);
m2_sdl_set_pixel(2,2);
*/

/* update all */
/* http://www.libsdl.org/cgi/docwiki.cgi/SDL_UpdateRect */
Expand Down Expand Up @@ -157,7 +159,6 @@ void m2_sdl_text(int x0, int y0, const char *s, int pos, int style)
m2_sdl_hline((x0+xs/m2_sdl_multiple), (x0+xe/m2_sdl_multiple), (y0-1));
if ( style ==2 )
m2_sdl_hline((x0+xs/m2_sdl_multiple), (x0+xe/m2_sdl_multiple), (y0-2));

}
}

Expand Down Expand Up @@ -364,12 +365,14 @@ void m2_sdlgfx_start(void)
Uint32 color = SDL_MapRGB( m2_sdl_screen->format, 0, 0, 0 );
/* http://www.libsdl.org/cgi/docwiki.cgi/SDL_FillRect */
SDL_FillRect(m2_sdl_screen, NULL, color);
/*
m2_sdl_set_pixel(0,0);
m2_sdl_set_pixel(10,0);
m2_sdl_set_pixel(20,0);
m2_sdl_set_pixel(30,0);
m2_sdl_set_pixel(40,0);
m2_sdl_set_pixel(50,0);
*/
}

void m2_sdlgfx_end(void)
Expand Down
1 change: 1 addition & 0 deletions sys/sdl_u8g/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ new tutorial
1) positive logic
2) analog input on one pin
3) auto repeat
4) key pad support


============
Expand Down
4 changes: 2 additions & 2 deletions sys/sdl_u8g_color/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2239,7 +2239,7 @@ int main(void)
u8g_Init(&u8g, &u8g_dev_sdl_8bit);
u8g_SetCursorFont(&u8g, u8g_font_cursor);
u8g_SetCursorColor(&u8g, 0x0c0, 3);
u8g_EnableCursor(&u8g);
// u8g_EnableCursor(&u8g);

/* 2. Now, setup m2 */
//m2_Init(&top_el_tlsm, m2_es_sdl, m2_eh_4bsts, m2_gh_u8g_bfs);
Expand All @@ -2253,7 +2253,7 @@ int main(void)
m2_SetU8g(&u8g, m2_u8g_box_icon);

/* 4. And finally, set at least one font, use normal u8g_font's */
m2_SetFont(0, (const void *)u8g_font_7x13);
m2_SetFont(0, (const void *)u8g_font_6x13);
m2_SetFont(1, (const void *)u8g_font_symb12);
m2_SetFont(2, (const void *)u8g_font_fub25);

Expand Down

0 comments on commit e40e55d

Please sign in to comment.