Interpolating temperature points and displaying them works
This commit is contained in:
commit
585b8875a4
|
@ -0,0 +1 @@
|
||||||
|
/bin
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "avr-st7735"]
|
||||||
|
path = avr-st7735
|
||||||
|
url = git@github.com:LongHairedHacker/avr-st7735.git
|
|
@ -0,0 +1,76 @@
|
||||||
|
AVRMCU ?= atmega8
|
||||||
|
F_CPU ?= 16000000
|
||||||
|
ISPPORT ?= /dev/kaboard
|
||||||
|
|
||||||
|
VERSION = 0.1
|
||||||
|
|
||||||
|
# ST7735 stuff
|
||||||
|
HEADERS = avr-st7735/include/spi.h
|
||||||
|
HEADERS += avr-st7735/include/st7735.h avr-st7735/include/st7735initcmds.h
|
||||||
|
HEADERS += avr-st7735/include/st7735_gfx.h avr-st7735/include/st7735_font.h
|
||||||
|
HEADERS += avr-st7735/images/logo_bw.h avr-st7735/fonts/free_sans.h
|
||||||
|
|
||||||
|
SRC = avr-st7735/spi.c avr-st7735/st7735.c
|
||||||
|
SRC += avr-st7735/st7735_gfx.c avr-st7735/st7735_font.c
|
||||||
|
|
||||||
|
# Local stuff
|
||||||
|
SRC += main.c
|
||||||
|
TARGET = reflow-firmware
|
||||||
|
OBJDIR = bin
|
||||||
|
|
||||||
|
CC = avr-gcc
|
||||||
|
OBJCOPY = avr-objcopy
|
||||||
|
OBJDUMP = avr-objdump
|
||||||
|
SIZE = avr-size
|
||||||
|
|
||||||
|
SRC_TMP = $(subst ../,,$(SRC))
|
||||||
|
OBJ = $(SRC_TMP:%.c=$(OBJDIR)/$(AVRMCU)/%.o)
|
||||||
|
|
||||||
|
CFLAGS = -I avr-st7735/include -I avr-st7735/images -I avr-st7735/fonts
|
||||||
|
CFLAGS += -Os -Wall -Wstrict-prototypes
|
||||||
|
CFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
CFLAGS += -fshort-enums -fpack-struct -funsigned-char -funsigned-bitfields
|
||||||
|
CFLAGS += -mmcu=$(AVRMCU) -DF_CPU=$(F_CPU)UL -DVERSION=$(VERSION)
|
||||||
|
|
||||||
|
LDFLAGS = -mmcu=$(AVRMCU) -Wl,--gc-sections
|
||||||
|
|
||||||
|
all: start $(OBJDIR)/$(AVRMCU)/$(TARGET).hex size
|
||||||
|
@echo ":: Done !"
|
||||||
|
|
||||||
|
start:
|
||||||
|
@echo "Reflow Firmware $(VERSION)"
|
||||||
|
@echo "=========================="
|
||||||
|
@echo ":: Building for $(AVRMCU)"
|
||||||
|
@echo ":: MCU operating frequency is $(F_CPU)Hz"
|
||||||
|
|
||||||
|
images/logo.h : images/logo.png utils/img_convert.py
|
||||||
|
python3 utils/img_convert.py $< $@
|
||||||
|
|
||||||
|
images/logo_bw.h : images/logo_bw.png utils/img_convert_mono.py
|
||||||
|
python3 utils/img_convert_mono.py $< $@
|
||||||
|
|
||||||
|
$(OBJDIR)/$(AVRMCU)/%.o : %.c $(HEADERS) Makefile
|
||||||
|
@mkdir -p $$(dirname $@)
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/$(AVRMCU)/$(TARGET).elf : $(OBJ)
|
||||||
|
$(CC) $(LDFLAGS) $+ -o $@
|
||||||
|
|
||||||
|
$(OBJDIR)/$(AVRMCU)/$(TARGET).hex : $(OBJDIR)/$(AVRMCU)/$(TARGET).elf
|
||||||
|
$(OBJCOPY) -O ihex $< $@
|
||||||
|
|
||||||
|
size : $(OBJDIR)/$(AVRMCU)/$(TARGET).elf
|
||||||
|
@echo
|
||||||
|
@$(SIZE) --mcu=$(AVRMCU) -C $(OBJDIR)/$(AVRMCU)/$(TARGET).elf
|
||||||
|
@echo
|
||||||
|
|
||||||
|
clean :
|
||||||
|
@rm -rf $(OBJDIR)
|
||||||
|
|
||||||
|
flash : all
|
||||||
|
avrdude -c arduino \
|
||||||
|
-p $(AVRMCU) -P $(ISPPORT) \
|
||||||
|
-U flash:w:$(OBJDIR)/$(AVRMCU)/$(TARGET).hex
|
||||||
|
|
||||||
|
test : flash
|
||||||
|
screen $(ISPPORT) 38400
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 3d03fa4038aea6ef89e1b17c6da0e9732284d912
|
|
@ -0,0 +1,79 @@
|
||||||
|
#include<avr/io.h>
|
||||||
|
#include<util/delay.h>
|
||||||
|
|
||||||
|
#include "spi.h"
|
||||||
|
#include "st7735.h"
|
||||||
|
#include "st7735_gfx.h"
|
||||||
|
#include "st7735_font.h"
|
||||||
|
|
||||||
|
#include "logo_bw.h"
|
||||||
|
|
||||||
|
#include "free_sans.h"
|
||||||
|
|
||||||
|
uint8_t profile_point_count = 5;
|
||||||
|
uint16_t profile[5][2] = {
|
||||||
|
{0, 22},
|
||||||
|
{90, 150},
|
||||||
|
{180, 180},
|
||||||
|
{210, 210},
|
||||||
|
{270, 180},
|
||||||
|
};
|
||||||
|
|
||||||
|
uint16_t interpolate_profile(uint16_t t) {
|
||||||
|
if(t > profile[profile_point_count -1][0]) {
|
||||||
|
return profile[profile_point_count -1][1] * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t pos;
|
||||||
|
for(pos = 0; pos < profile_point_count; pos++) {
|
||||||
|
if(profile[pos][0] > t) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int16_t time_diff = profile[pos][0] - profile[pos - 1][0];
|
||||||
|
int16_t tmp_diff = (profile[pos][1] - profile[pos - 1][1]) * 100;
|
||||||
|
int16_t gradient = tmp_diff / time_diff;
|
||||||
|
|
||||||
|
return gradient * (t - profile[pos - 1][0]) + profile[pos - 1][1] * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void splash_screen(void) {
|
||||||
|
st7735_fill_rect(0, 0, 160, 128, ST7735_COLOR_BLACK);
|
||||||
|
st7735_draw_mono_bitmap(16, 4, &logo_bw, ST7735_COLOR_WHITE, ST7735_COLOR_BLACK);
|
||||||
|
_delay_ms(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_plot_template(void) {
|
||||||
|
st7735_fill_rect(0, 0, 160, 128, ST7735_COLOR_BLACK);
|
||||||
|
|
||||||
|
for(uint8_t y = 28; y < 128; y += 10) {
|
||||||
|
st7735_draw_fast_hline(0, y, 160, st7735_color(128,128,128));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint8_t x = 10; x < 160; x+=10) {
|
||||||
|
st7735_draw_fast_vline(x, 20, 128, st7735_color(128,128,128));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint8_t t = 0; t < 160; t++) {
|
||||||
|
uint16_t temp = interpolate_profile(t * 2);
|
||||||
|
|
||||||
|
st7735_draw_pixel(t, 127 - (temp / 250), ST7735_COLOR_CYAN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
spi_init();
|
||||||
|
st7735_init();
|
||||||
|
|
||||||
|
st7735_set_orientation(ST7735_LANDSCAPE);
|
||||||
|
|
||||||
|
splash_screen();
|
||||||
|
|
||||||
|
draw_plot_template();
|
||||||
|
|
||||||
|
|
||||||
|
while(1);
|
||||||
|
}
|
Loading…
Reference in New Issue