Skip to content

Commit

Permalink
Some bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bsaxen committed Dec 12, 2011
1 parent 340bc5b commit ce47101
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 33 deletions.
46 changes: 33 additions & 13 deletions decode_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,17 @@ void digitalWrite(int pin,int value)
wmove(uno,digActRow[pin],digActCol[pin]);
wprintw(uno,"w");
show(uno);
wmove(uno,digPinRow[pin],digPinCol[pin]-2);
wprintw(uno,"%3d",value);
iDelay(confDelay);
if(value < 10)
{
wmove(uno,digPinRow[pin],digPinCol[pin]);
wprintw(uno,"%1d",value);
}
else
{
wmove(uno,digPinRow[pin],digPinCol[pin]-2);
wprintw(uno,"%3d",value);
}
wmove(uno,digActRow[pin],digActCol[pin]);
wprintw(uno," ");
show(uno);
Expand All @@ -127,10 +136,6 @@ int digitalRead(int pin)

currentValueD[pin] = value;

wmove(uno,dp+2,digPinCol[pin]);
wprintw(uno,"r");
show(uno);

strcpy(temp,textDigitalRead[pin]);
if(confLogLev > 0)
{
Expand All @@ -140,12 +145,24 @@ int digitalRead(int pin)
wLog2(temp,pin,value);
}


wmove(uno,dp,digPinCol[pin]);
wprintw(uno,"%1d",value);
wmove(uno,dp+2,digPinCol[pin]);
wmove(uno,digActRow[pin],digActCol[pin]);
wprintw(uno,"r");
show(uno);
iDelay(confDelay);
if(value < 10)
{
wmove(uno,digPinRow[pin],digPinCol[pin]);
wprintw(uno,"%1d",value);
}
else
{
wmove(uno,digPinRow[pin],digPinCol[pin]-2);
wprintw(uno,"%3d",value);
}
wmove(uno,digActRow[pin],digActCol[pin]);
wprintw(uno," ");
show(uno);

}
else
{
Expand Down Expand Up @@ -198,13 +215,15 @@ int analogRead(int pin) // Values 0 to 1023


wmove(uno,ap-2,anaPinCol[pin]);
wprintw(uno," ");

wprintw(uno,"r");
show(uno);
iDelay(confDelay);
wmove(uno,ap+1,anaPinCol[pin]);
waddch(uno,ACS_VLINE);
wmove(uno,ap+2,anaPinCol[pin]-1);
wprintw(uno,"In");

wmove(uno,ap-2,anaPinCol[pin]);
wprintw(uno," ");
show(uno);
return(value);
}
Expand Down Expand Up @@ -235,6 +254,7 @@ void analogWrite(int pin,int value)
wmove(uno,digActRow[pin],digActCol[pin]);
wprintw(uno,"a");
show(uno);
iDelay(confDelay);
strcpy(temp,textAnalogWrite[pin]);
if(strstr(temp,"void"))
wLog2("analogWrite",pin,value);
Expand Down
52 changes: 44 additions & 8 deletions helloWorld_MEGA.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//================================================
// Example HelloWorld
//================================================
// SKETCH_NAME: HelloWorld
// SKETCH_NAME: HelloWorld_MEGA
// BOARD_TYPE MEGA
// SCENSIMLEN 600
//================================================
Expand Down Expand Up @@ -46,8 +46,8 @@
// Leds
int URGENTLED = 31;
int BLINKLED = 32;
int IN_PIN = 20;
int CONTROL = 19;
int IN_PIN = 52;
int CONTROL = 53;

//-------- ANALOGUE PIN settings
int SENSOR1 = 4;
Expand All @@ -60,28 +60,64 @@ int SENSOR2 = 5;
void blinkLed(int n);

//================================================
void urgent()
void urgent0()
//================================================
{
digitalWrite(URGENTLED, HIGH);
delay(400);
digitalWrite(URGENTLED, LOW);
}
//================================================
void urgent1()
//================================================
{
digitalWrite(URGENTLED, HIGH);
delay(401);
digitalWrite(URGENTLED, LOW);
}
//================================================
void very_urgent()
void urgent2()
//================================================
{
digitalWrite(URGENTLED, HIGH);
delay(402);
digitalWrite(URGENTLED, LOW);
}
//================================================
void urgent3()
//================================================
{
digitalWrite(URGENTLED, HIGH);
delay(403);
digitalWrite(URGENTLED, LOW);
}
//================================================
void urgent4()
//================================================
{
digitalWrite(URGENTLED, HIGH);
delay(404);
digitalWrite(URGENTLED, LOW);
}
//================================================
void urgent5()
//================================================
{
digitalWrite(URGENTLED, HIGH);
delay(405);
digitalWrite(URGENTLED, LOW);
}
//================================================
void setup()
//================================================
{
Serial.begin(9600);
attachInterrupt(0,urgent, CHANGE);
attachInterrupt(1,very_urgent, RISING);
attachInterrupt(0,urgent0, CHANGE);
attachInterrupt(1,urgent1, RISING);
attachInterrupt(2,urgent2, FALLING);
attachInterrupt(3,urgent3, LOW);
attachInterrupt(4,urgent4, CHANGE);
attachInterrupt(5,urgent5, RISING);
pinMode(BLINKLED,OUTPUT);
pinMode(URGENTLED,OUTPUT);
pinMode(IN_PIN,INPUT);
Expand Down Expand Up @@ -128,7 +164,7 @@ void blinkLed(int n)
//================================================
{
int i;
for(i=1;i<=10;i++)
for(i=1;i<=2;i++)
{
digitalWrite(BLINKLED, HIGH);
delay(500);
Expand Down
2 changes: 1 addition & 1 deletion helloWorld_UNO.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//================================================
// Simuino log text customization
//================================================
// SKETCH_NAME: HelloWorld
// SKETCH_NAME: HelloWorld_UNO

// PINMODE_OUT: 11 "PIN: Led Urgent"
// PINMODE_OUT: 12 "PIN: Led Blink"
Expand Down
27 changes: 20 additions & 7 deletions simuino.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,17 @@ void openCommand()
while(strstr(str,"ex") == NULL)
{
if(currentStep == g_steps)endOfSimulation();

anyErrors();
unoInfo();

wmove(uno,board_h-2,1);
wprintw(uno," ");
if(g_silent==NO )mvwprintw(uno,board_h-2,1,"A%1d>",confWinMode);
if(g_silent==YES)mvwprintw(uno,board_h-2,1,"A%1d<",confWinMode);
show(uno);
wmove(uno,board_h-2,4);

strcpy(command[0],"");

anyErrors();
wgetstr(uno,str);

n = tokCommand(command,str);
Expand Down Expand Up @@ -469,6 +471,7 @@ void openCommand()
g_pinStep = atoi(command[3]);
g_pinValue = atoi(command[4]);

ok = S_OK;
if(g_pinType == ANA)
ok = checkRange(S_OK,"anapin",g_pinNo);
if(g_pinType == DIG)
Expand Down Expand Up @@ -737,15 +740,15 @@ void runMode(int stop)
while(1)
{
if(currentStep == g_steps)endOfSimulation();
wmove(uno,board_h-2,1);
wprintw(uno," ");

anyErrors();
if(g_silent==NO )mvwprintw(uno,board_h-2,1,"R%1d>",confWinMode);
if(g_silent==YES)mvwprintw(uno,board_h-2,1,"R%1d<",confWinMode);
unoInfo();

show(uno);
// wmove(uno,board_h-2,1);
// wprintw(uno," ");

anyErrors();

ch = getchar();

Expand Down Expand Up @@ -829,6 +832,7 @@ void runMode(int stop)
if(strstr(temp,"q") == NULL)
{
sscanf(temp,"%d%d",&ir,&x);
ok = S_OK;
ok = ok + checkRange(S_OK,"interrupt",ir);
ok = ok + checkRange(S_OK,"digval",x);
ok = ok + checkRange(S_OK,"step",step);
Expand Down Expand Up @@ -871,6 +875,7 @@ void runMode(int stop)
if(strstr(temp,"q") == NULL)
{
x = atoi(temp);
ok = S_OK;
if(res == ANA)ok = ok + checkRange(S_OK,"anaval",x);
if(res == DIG)ok = ok + checkRange(S_OK,"digval",x);
if(ok == S_OK)
Expand Down Expand Up @@ -946,6 +951,14 @@ int main(int argc, char *argv[])

sprintf(syscom,"ls *.conf > %s;",fileProjList);
x=system(syscom);
sprintf(syscom,"rm %s;touch %s;",fileTemp,fileTemp);
x=system(syscom);
sprintf(syscom,"rm %s;touch %s;",fileError,fileError);
x=system(syscom);
sprintf(syscom,"rm %s;touch %s;",fileServError,fileServError);
x=system(syscom);
sprintf(syscom,"rm %s;touch %s;",fileCopyError,fileCopyError);
x=system(syscom);

readConfig(currentConf);

Expand Down
15 changes: 11 additions & 4 deletions simuino_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ void show(WINDOW *win)
}

wmove(uno,board_h-2,4);
wprintw(uno," ");
wmove(uno,board_h-2,4);
wrefresh(uno);
wrefresh(win);
iDelay(confDelay);
//iDelay(confDelay);
}

//====================================
Expand Down Expand Up @@ -422,6 +425,8 @@ void wLog2(const char *p, int value1, int value2)
wprintw(slog,">%s",simulation[currentStep+1]);
wmove(slog,2,1);
if(g_silent == 0)wprintw(slog,"%s",temp);

wmove(uno,board_h-2,4);
show(slog);
}

Expand All @@ -441,7 +446,7 @@ void unoInfo()
else
wprintw(uno," ");

show(slog);
show(uno);
}

//====================================
Expand Down Expand Up @@ -1366,20 +1371,22 @@ int countRowsInFile(char *fileName)
fclose(in);
return(res);
}
return(999);
}
//====================================
void anyErrors()
//====================================
{
int x;
char syscom[120];
char syscom[200];

g_existError = NO;
x = system("rm temp.txt");
sprintf(syscom,"cat %s %s %s> %s",fileError,fileServError,fileCopyError,fileTemp);
x = system(syscom);
x = countRowsInFile(fileTemp);
if(x > 0)g_existError = YES;
if(x > 0 && x != 999)g_existError = YES;
if(x == 999)putMsg(2,"Unable to read error file");
show(uno);
}

Expand Down

0 comments on commit ce47101

Please sign in to comment.