feature-complete replacement for BASIC control software...w00t!
git-svn-id: https://svn.salfter.gotdns.org/svn/a2bfc/trunk@92 1b90f75b-8b96-4784-87c0-14078182fce6
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,7 +1,7 @@
|
|||||||
all: CFRIDGE
|
all: CFRIDGE
|
||||||
|
|
||||||
CFRIDGE: *.c *.h *.s
|
CFRIDGE: *.c *.h *.s
|
||||||
cl65 -C apple2.cfg -t apple2enh -o CFRIDGE *.c *.s
|
cl65 -C apple2-tgi.cfg -t apple2enh -o CFRIDGE *.c *.s
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm *.o CFRIDGE
|
-rm *.o CFRIDGE
|
||||||
|
|||||||
BIN
a2e.hi.tgi
Normal file
BIN
a2e.hi.tgi
Normal file
Binary file not shown.
39
apple2-tgi.cfg
Normal file
39
apple2-tgi.cfg
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
FEATURES {
|
||||||
|
STARTADDRESS: default = $4000;
|
||||||
|
}
|
||||||
|
MEMORY {
|
||||||
|
ZP: start = $0080, size = $001A, define = yes;
|
||||||
|
HEADER: start = $0000, size = $0004, file = "";
|
||||||
|
RAM: start = $4000, size = $7600, file = %O;
|
||||||
|
}
|
||||||
|
SEGMENTS {
|
||||||
|
EXEHDR: load = HEADER, type = ro;
|
||||||
|
STARTUP: load = RAM, type = ro, define = yes;
|
||||||
|
LOWCODE: load = RAM, type = ro, optional = yes;
|
||||||
|
INIT: load = RAM, type = ro, define = yes, optional = yes;
|
||||||
|
CODE: load = RAM, type = ro;
|
||||||
|
RODATA: load = RAM, type = ro;
|
||||||
|
DATA: load = RAM, type = rw;
|
||||||
|
BSS: load = RAM, type = bss, define = yes;
|
||||||
|
HEAP: load = RAM, type = bss, optional = yes; # must sit just below stack
|
||||||
|
ZEROPAGE: load = ZP, type = zp;
|
||||||
|
}
|
||||||
|
FEATURES {
|
||||||
|
CONDES: segment = INIT,
|
||||||
|
type = constructor,
|
||||||
|
label = __CONSTRUCTOR_TABLE__,
|
||||||
|
count = __CONSTRUCTOR_COUNT__;
|
||||||
|
CONDES: segment = RODATA,
|
||||||
|
type = destructor,
|
||||||
|
label = __DESTRUCTOR_TABLE__,
|
||||||
|
count = __DESTRUCTOR_COUNT__;
|
||||||
|
CONDES: type = interruptor,
|
||||||
|
segment = RODATA,
|
||||||
|
label = __INTERRUPTOR_TABLE__,
|
||||||
|
count = __INTERRUPTOR_COUNT__;
|
||||||
|
}
|
||||||
|
SYMBOLS {
|
||||||
|
__STACKSIZE__ = $800; # 2K stack
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
83
main.c
83
main.c
@@ -3,6 +3,9 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <peekpoke.h>
|
#include <peekpoke.h>
|
||||||
|
#include <modload.h>
|
||||||
|
#include <tgi.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "ow.h"
|
#include "ow.h"
|
||||||
#include "ow-temp.h"
|
#include "ow-temp.h"
|
||||||
#include "ow-time.h"
|
#include "ow-time.h"
|
||||||
@@ -11,6 +14,7 @@
|
|||||||
COMP_STATUS compressor_status;
|
COMP_STATUS compressor_status;
|
||||||
unsigned char* tempsensor=NULL;
|
unsigned char* tempsensor=NULL;
|
||||||
unsigned char* clockdev=NULL;
|
unsigned char* clockdev=NULL;
|
||||||
|
unsigned char tempsamples[280];
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
@@ -24,6 +28,17 @@ int main (void)
|
|||||||
time_t shutoff=0;
|
time_t shutoff=0;
|
||||||
unsigned char cmd;
|
unsigned char cmd;
|
||||||
time_t gototime=0;
|
time_t gototime=0;
|
||||||
|
time_t lastupdate=0;
|
||||||
|
|
||||||
|
for (i=0; i<280; i++)
|
||||||
|
tempsamples[i]=70;
|
||||||
|
|
||||||
|
tgi_load(TGI_MODE_280_192_6);
|
||||||
|
if (tgi_geterror()!=TGI_ERR_OK)
|
||||||
|
{
|
||||||
|
printf("tgi_load() failed\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
devcount=ow_enumeratedevices(devs, 10);
|
devcount=ow_enumeratedevices(devs, 10);
|
||||||
|
|
||||||
@@ -59,17 +74,24 @@ int main (void)
|
|||||||
clrscr();
|
clrscr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tgi_init(); // turn on Hi-Res mode
|
||||||
|
POKE(-16301,0); // make it split-screen
|
||||||
|
drawgraph(70);
|
||||||
|
if (tgi_geterror()!=TGI_ERR_OK)
|
||||||
|
{
|
||||||
|
printf("tgi_init() failed\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
relayctrl(0);
|
relayctrl(0);
|
||||||
gotoxy(25,0);
|
gotoxy(25,20);
|
||||||
printf("off ");
|
printf("off ");
|
||||||
gotoxy(0,2);
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
t=ow_time_read(clockdev);
|
t=ow_time_read(clockdev);
|
||||||
currtemp=ow_temp_read(tempsensor, OW_TEMP_FAHRENHEIT);
|
currtemp=ow_temp_read(tempsensor, OW_TEMP_FAHRENHEIT);
|
||||||
gotoxy(0,0);
|
gotoxy(0,20);
|
||||||
printf("curr=%i set=%i goto=%i \n",
|
printf("curr=%i set=%i goto=%i \n",
|
||||||
currtemp,
|
currtemp,
|
||||||
setpoint,
|
setpoint,
|
||||||
@@ -83,30 +105,35 @@ int main (void)
|
|||||||
intime.tm_min,
|
intime.tm_min,
|
||||||
intime.tm_sec);
|
intime.tm_sec);
|
||||||
printf(" \n");
|
printf(" \n");
|
||||||
|
if (t>lastupdate+60)
|
||||||
|
{
|
||||||
|
lastupdate=t;
|
||||||
|
drawgraph(currtemp);
|
||||||
|
}
|
||||||
gotoy(wherey()-1);
|
gotoy(wherey()-1);
|
||||||
if (currtemp>=setpoint+2 && compressor_status==COMP_OFF)
|
if (currtemp>=setpoint+2 && compressor_status==COMP_OFF)
|
||||||
{
|
{
|
||||||
if (t-shutoff>300)
|
if (t-shutoff>300)
|
||||||
{
|
{
|
||||||
relayctrl(1);
|
relayctrl(1);
|
||||||
gotoxy(25,0);
|
gotoxy(25,20);
|
||||||
printf("on ");
|
printf("on ");
|
||||||
gotoxy(0,2);
|
gotoxy(0,22);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gotoxy(25,0);
|
gotoxy(25,20);
|
||||||
printf("wait");
|
printf("wait");
|
||||||
gotoxy(0,2);
|
gotoxy(0,22);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currtemp<=setpoint-2 && compressor_status==COMP_ON)
|
if (currtemp<=setpoint-2 && compressor_status==COMP_ON)
|
||||||
{
|
{
|
||||||
relayctrl(0);
|
relayctrl(0);
|
||||||
shutoff=t;
|
shutoff=t;
|
||||||
gotoxy(25,0);
|
gotoxy(25,20);
|
||||||
printf("off ");
|
printf("off ");
|
||||||
gotoxy(0,2);
|
gotoxy(0,22);
|
||||||
}
|
}
|
||||||
if (t>=gototime && gotopoint!=setpoint)
|
if (t>=gototime && gotopoint!=setpoint)
|
||||||
{
|
{
|
||||||
@@ -244,3 +271,41 @@ void relayctrl(unsigned char on)
|
|||||||
compressor_status=(on)?COMP_ON:COMP_OFF;
|
compressor_status=(on)?COMP_ON:COMP_OFF;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawgraph(unsigned char newsample)
|
||||||
|
{
|
||||||
|
unsigned int x, y;
|
||||||
|
char mkr[3]="00";
|
||||||
|
|
||||||
|
tgi_setcolor(0);
|
||||||
|
tgi_setpixel(0,yscale(tempsamples[0]));
|
||||||
|
tgi_gotoxy(0,yscale(tempsamples[0]));
|
||||||
|
for (x=1; x<280; x++)
|
||||||
|
{
|
||||||
|
tgi_lineto(x,yscale(tempsamples[x]));
|
||||||
|
tempsamples[x-1]=tempsamples[x];
|
||||||
|
}
|
||||||
|
tempsamples[279]=newsample;
|
||||||
|
for (y=30; y<=90; y+=10)
|
||||||
|
{
|
||||||
|
tgi_setcolor(1);
|
||||||
|
tgi_line(14,yscale(y),279,yscale(y));
|
||||||
|
tgi_setcolor(3);
|
||||||
|
mkr[0]=48+(y/10);
|
||||||
|
tgi_outtextxy(0,yscale(y)-4,mkr);
|
||||||
|
}
|
||||||
|
tgi_setpixel(0,yscale(tempsamples[0]));
|
||||||
|
tgi_gotoxy(0,yscale(tempsamples[0]));
|
||||||
|
for (x=1; x<280; x++)
|
||||||
|
tgi_lineto(x,yscale(tempsamples[x]));
|
||||||
|
}
|
||||||
|
|
||||||
|
int yscale(int y)
|
||||||
|
{
|
||||||
|
if (y>90) // clamp to within range
|
||||||
|
y=90;
|
||||||
|
if (y<30)
|
||||||
|
y=30;
|
||||||
|
return 5+(90-y)*5/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
2
main.h
2
main.h
@@ -8,5 +8,7 @@ int readYN();
|
|||||||
int readnum(int defval, unsigned char timeout);
|
int readnum(int defval, unsigned char timeout);
|
||||||
void backup();
|
void backup();
|
||||||
void relayctrl(unsigned char on);
|
void relayctrl(unsigned char on);
|
||||||
|
void drawgraph(unsigned char newsample);
|
||||||
|
int yscale(int y);
|
||||||
|
|
||||||
#endif // _MAIN_H
|
#endif // _MAIN_H
|
||||||
|
|||||||
Reference in New Issue
Block a user