First commit of partly-working reflow oven controller.
This commit is contained in:
23
test/Makefile
Normal file
23
test/Makefile
Normal file
@@ -0,0 +1,23 @@
|
||||
# Makefile
|
||||
|
||||
VPATH = ..
|
||||
|
||||
OBJECTS.test-menu = test-menu.o test-display.o menu.o test-therm.o config.o
|
||||
OBJECTS.test-graphics = test-graphics.o menu.o test-i2c.o display.o test-therm.o config.o font.o fields.o profile.o control.o
|
||||
|
||||
CFLAGS = -Wall -Werror -Os -I. -I..
|
||||
LDLIBS = -lncurses
|
||||
|
||||
CFLAGS+=`pkg-config --cflags sdl SDL_gfx`
|
||||
LDLIBS+=`pkg-config --libs sdl SDL_gfx`
|
||||
LDLIBS+=-lm
|
||||
|
||||
#all: test-menu test-graphics
|
||||
all: test-graphics
|
||||
|
||||
test-menu: $(OBJECTS.test-menu)
|
||||
|
||||
test-graphics: $(OBJECTS.test-graphics)
|
||||
|
||||
clean:
|
||||
rm -f test-menu $(OBJECTS.test-menu) $(OBJECTS.test-graphics)
|
||||
0
test/avr/io.h
Normal file
0
test/avr/io.h
Normal file
13
test/avr/pgmspace.h
Normal file
13
test/avr/pgmspace.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef _PGMSPACE_H_
|
||||
#define _PGMSPACE_H_
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define PROGMEM
|
||||
#define PGM_P const char *
|
||||
#define pgm_read_byte(x) (*(char *)(x))
|
||||
#define pgm_read_ptr(x) (*(char **)(x))
|
||||
#define strlen_P strlen
|
||||
#define memcpy_P memcpy
|
||||
|
||||
#endif
|
||||
68
test/test-display.c
Normal file
68
test/test-display.c
Normal file
@@ -0,0 +1,68 @@
|
||||
/* test-display.c */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
unsigned int curpos;
|
||||
|
||||
void display_cleanup(void)
|
||||
{
|
||||
endwin();
|
||||
}
|
||||
|
||||
void display_data(uint8_t len, uint8_t *data)
|
||||
{
|
||||
/* can't do anything with this graphics */
|
||||
}
|
||||
|
||||
void display_init(void)
|
||||
{
|
||||
initscr();
|
||||
noecho();
|
||||
atexit(display_cleanup);
|
||||
}
|
||||
|
||||
void display_setposition(char col, char row)
|
||||
{
|
||||
move(row, col/6);
|
||||
curpos = col/6;
|
||||
//printf("Position set to row %d, col %d\n", row, col/6);
|
||||
}
|
||||
|
||||
void display_setinverse(bool on)
|
||||
{
|
||||
if (on)
|
||||
attron(A_REVERSE);
|
||||
else
|
||||
attroff(A_REVERSE);
|
||||
//printf("Inverse set to %s\n", on?"on":"off");
|
||||
}
|
||||
|
||||
void display_putchar(char c)
|
||||
{
|
||||
printw("%c", c);
|
||||
refresh();
|
||||
curpos++;
|
||||
//printf("Put character %c\n", c);
|
||||
}
|
||||
|
||||
void display_putstr(char *s)
|
||||
{
|
||||
while (*s)
|
||||
display_putchar(*(s++));
|
||||
}
|
||||
|
||||
void display_putstr_P(const char *s)
|
||||
{
|
||||
display_putstr((char *)s);
|
||||
}
|
||||
|
||||
void display_clearline(void)
|
||||
{
|
||||
while (curpos < 21) {
|
||||
display_putchar(' ');
|
||||
}
|
||||
//printf("Cleared line\n");
|
||||
}
|
||||
70
test/test-graphics.c
Normal file
70
test/test-graphics.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/* test-graphics.c */
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_gfxPrimitives.h"
|
||||
#include "menu.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
SDL_Surface *screen;
|
||||
|
||||
SDL_Event event;
|
||||
|
||||
#define WHITE 0xffffffff
|
||||
|
||||
int button = 0;
|
||||
|
||||
uint32_t seconds;
|
||||
uint8_t output0;
|
||||
|
||||
void beep_off(void)
|
||||
{
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
screen = SDL_SetVideoMode(128, 64, 16, SDL_SWSURFACE);
|
||||
|
||||
SDL_WM_SetCaption("Reflow oven controller", "Reflow oven controller");
|
||||
|
||||
bool done=FALSE;
|
||||
|
||||
menu_init();
|
||||
|
||||
while(!done) {
|
||||
while(SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_QUIT) {
|
||||
done=TRUE;
|
||||
}
|
||||
if (event.type == SDL_KEYDOWN) {
|
||||
switch(event.key.keysym.sym) {
|
||||
case SDLK_UP:
|
||||
button = 1;
|
||||
break;
|
||||
case SDLK_DOWN:
|
||||
button = 2;
|
||||
break;
|
||||
case SDLK_LEFT:
|
||||
button = 4;
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
button = 3;
|
||||
break;
|
||||
case SDLK_q:
|
||||
done = TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
menu_poll();
|
||||
SDL_Flip(screen);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
62
test/test-i2c.c
Normal file
62
test/test-i2c.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/* i2c.c */
|
||||
|
||||
#include "common.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL_gfxPrimitives.h"
|
||||
|
||||
|
||||
#define WHITE 0xffffffff
|
||||
#define BLACK 0x000000ff
|
||||
|
||||
uint8_t i2c_xor;
|
||||
uint8_t page;
|
||||
uint8_t col;
|
||||
|
||||
|
||||
extern SDL_Surface *screen;
|
||||
|
||||
void i2c_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void i2c_set_xor(char xor)
|
||||
{
|
||||
i2c_xor = xor;
|
||||
}
|
||||
|
||||
bool i2c_write(char address, char prefix, char bytes, char *data)
|
||||
{
|
||||
uint8_t i, j;
|
||||
|
||||
switch ((uint8_t) prefix) {
|
||||
case 0x80:
|
||||
switch (data[0] & 0xf0) {
|
||||
case 0xb0:
|
||||
page = data[0] & 0xf;
|
||||
break;
|
||||
case 0x00:
|
||||
col = (col & ~0xf) + (data[0] & 0xf);
|
||||
break;
|
||||
case 0x10:
|
||||
col = (col & 0xf) + ((data[0] & 0xf) << 4);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 0x40:
|
||||
for (i = 0; i < bytes; i++) {
|
||||
uint8_t byte = data[i] ^ i2c_xor;
|
||||
for (j = 0; j < 8; j++) {
|
||||
pixelColor(screen, col, page*8 + j, (byte & 1)?WHITE:BLACK);
|
||||
byte = byte >> 1;
|
||||
}
|
||||
col++;
|
||||
if (col > 127)
|
||||
col = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
46
test/test-menu.c
Normal file
46
test/test-menu.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/* test-menu.c */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ncurses.h>
|
||||
#include "display.h"
|
||||
#include "menu.h"
|
||||
|
||||
int button = 0;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/*
|
||||
display_init();
|
||||
display_putstr("Hello, world!");
|
||||
*/
|
||||
|
||||
menu_init();
|
||||
keypad(stdscr, TRUE);
|
||||
menu_poll();
|
||||
|
||||
while (1) {
|
||||
int c = getch();
|
||||
switch (c) {
|
||||
case KEY_UP:
|
||||
button = 1;
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
button = 2;
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
button = 3;
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
button = 4;
|
||||
break;
|
||||
case 'q':
|
||||
case 'Q':
|
||||
exit(0);
|
||||
}
|
||||
menu_poll();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
49
test/test-therm.c
Normal file
49
test/test-therm.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/* test-therm.c */
|
||||
|
||||
#include "common.h"
|
||||
#include "therm.h"
|
||||
|
||||
int32_t extend24(int32_t n)
|
||||
{
|
||||
if (n & 0x00800000) {
|
||||
return n | (~0 & 0xff000000);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
temp_t therm_temp(void)
|
||||
{
|
||||
// return extend24(0xf06000);
|
||||
return 3932;
|
||||
#if 0
|
||||
return 0x078000;
|
||||
return 0x064f00;
|
||||
return 0x52d000;
|
||||
#endif
|
||||
}
|
||||
|
||||
temp_t therm_coldtemp(void)
|
||||
{
|
||||
return 2987;
|
||||
#if 0
|
||||
return 0x19800;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t therm_fault(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
temp_t therm_reduce(int32_t temp)
|
||||
{
|
||||
temp = (temp * 10) / 4096;
|
||||
temp += 2732;
|
||||
if (temp < 0)
|
||||
temp = 0;
|
||||
if (temp > 65535)
|
||||
temp = 65535;
|
||||
|
||||
return (temp_t) temp;
|
||||
}
|
||||
|
||||
23
test/types.h
Normal file
23
test/types.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/* types.h */
|
||||
|
||||
#ifndef _TYPES_H_
|
||||
#define _TYPES_H_
|
||||
|
||||
/* Probably right for a PC */
|
||||
|
||||
typedef unsigned char uint8;
|
||||
typedef signed char int8;
|
||||
|
||||
typedef unsigned short uint16;
|
||||
typedef signed short int16;
|
||||
|
||||
typedef unsigned int uint32;
|
||||
typedef signed int int32;
|
||||
|
||||
#ifndef TRUE
|
||||
typedef unsigned char bool;
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
1
test/util/atomic.h
Normal file
1
test/util/atomic.h
Normal file
@@ -0,0 +1 @@
|
||||
#define ATOMIC_BLOCK(x)
|
||||
Reference in New Issue
Block a user