Hi,
In the following code the button iWinbutton isnt working, only seen graphicaly, the state flag is stuck in ' 0 '. it looks like the Repeat/Forever loop isnt working.
The first repeat is before "state := touch_Get(TOUCH_STATUS);" and the associate forever is at the end, before endfunc. so why it isnt looping?
The code:
"
#platform "uLCD-43PT"
#inherit "4DGL_16bitColours.fnc"
#inherit "VisualConst.inc"
#inherit "DiExMonitorConst.inc"
#inherit "PrintDiskGoldelox.inc"
#inherit "LedDigitsDisplayGoldelox.inc"
var combuf[24]; // 24 vars = 48 bytes
var combuffer[1]; // 24 vars = 48 bytes
var page ;
func main()
var chr,char, e, e2, n, frame, state;
var numx, dir, colr, redo, numt, Wbs1, i, x, y ;
e := 0;
e2 := 0;
gfx_Set(SCREEN_MODE,LANDSCAPE) ;
gfx_Set(CONTRAST,5) ;
txt_Set(TEXT_OPACITY, OPAQUE);
numx := 0 ;
//com1_Reset();
// Uncomment the following if uSD images used.
// putstr("Mounting...\n");
if (!(disk:=file_Mount()))
while(!(disk :=file_Mount()))
// putstr("Drive not mounted...");
pause(200);
gfx_Cls();
pause(200);
wend
endif
gfx_TransparentColour(0x0020);
gfx_Transparency(ON);
pin_Set(OUTPUT, AUDIO_ENABLE);
pin_HI(AUDIO_ENABLE);
hndl := file_LoadImageControl("DIEXMO~1.dat", "DIEXMO~1.gci", 1);
// image1 1.0 generated 30/05/2014 11:38:29
//img_Show(hndl,iimage1) ;
// pause(5000);
if(file_Exists("bl16k.wav"))
snd_BufSize(3);
snd_Volume(127);
file_PlayWAV("bl16k.wav");
while(snd_Playing());
else
putstr("bl16k.wav not found");
endif
if(file_Exists("intro1.wav"))
snd_BufSize(3);
snd_Volume(127);
file_PlayWAV("intro1.wav");
while(snd_Playing());
else
putstr("intro1.wav not found");
endif
*/
// gfx_Set(OUTLINE_COLOUR, DARKOLIVEGREEN); // set outline colour, gfx_Cls() will draw outline
// gfx_Cls();
// Image5 1.0 generated 26/08/2014 23:28:47
//img_Show(hndl,iImage5) ;
// Winbutton1 1.0 generated 26/08/2014 23:51:14
img_ClearAttributes(hndl, iWinbutton1, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
img_Show(hndl, iWinbutton1); // show button, only do this once
print("State 0"); // print initial state
touch_Set(TOUCH_ENABLE); // enable touch detection
// gfx_Cls();
repeat
state := touch_Get(TOUCH_STATUS); //get touch screen status
n := img_Touched(hndl,iWinbutton1);
//---------------------------------------------------------------------------
if(state == TOUCH_PRESSED) //if there's a press
if(n == iWinbutton1) //and if it's inside the button
img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, 1); //change state to state 1
img_Show(hndl, iWinbutton1); //show button
gfx_MoveTo(0,0); //move origin to point (0,0)
print("State 1"); //print state
endif
endif
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
if(state == TOUCH_RELEASED) //if there's a release
if(n == iWinbutton1) //and if it's inside the button
img_SetWord(hndl, iWinbutton1, IMAGE_INDEX,0); //change state to state 0
img_Show(hndl, iWinbutton1); //show button
gfx_MoveTo(0,0); //move origin to point (0,0)
print("State 0"); //print state
endif
endif
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
if(state == TOUCH_MOVING) //if there's movement
if(n == iWinbutton1) //and if it's inside the button
img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, 1); //change state to state 1
img_Show(hndl, iWinbutton1); //show button
gfx_MoveTo(0,0); //move origin to point (0,0)
print("State 1"); //print state
else //if movement is outside the button
img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, 0); //change state to state 0
img_Show(hndl, iWinbutton1); //show button
gfx_MoveTo(0,0); //move origin to point (0,0)
print("State 0"); //print state
endif
endif
//----------------------------------------------------------------------------
repeat
// setbaud(BAUD_9600); // 9600 baud comms
com_SetBaud(COM1,960);
com1_Init(combuf, 48, 0); // set up a comms circular buffer, use the entire buffer, no sync character
repeat
sys_SetTimer(TIMER0, 2000); // set delay so we stay in next loop for 5 seconds
// wait for a while gathering bytes
// and continuously displaying the count
// of characters in the buffer.
//// repeat
// Video1 1.0 generated 16/11/2013 18:32:51
// txt_MoveCursor(2,1); // reset cursor to line 3, column 2
// print("Buffered ", [DEC2Z] ( com_Count() )); // show count of chars in buffer
until (! sys_GetTimer(TIMER0)); // loop until TIME_OUT register is 0
/*
if (com_Full())
txt_MoveCursor(3,1); // reset cursor to line 5, column 2
print("Buffer Full ", (++e) ); // print error count
endif
if (com_Error())
txt_MoveCursor(4,1); // reset cursor to line 7, column 2
print("Comms Error ", (++e2) ); // print error count
endif
*/
// now dump whatever we got to the terminal
while ( (char := serin1()) >= 0)
// txt_Set(TEXT_COLOUR, RED);
gfx_MoveTo(0,0);
// print("\n'",[CHR]char,"' is ");
to(COM1); putch(char); // send buffered chars to com port
//wend
/*
txt_Set(FONT_ID, 0);
txt_MoveCursor(0,1); // reset cursor to line 1, column 2
putstr("Serial Echo\n9600 baud");
*/
switch
case (char == 'A')
// Image2 1.0 generated 22/08/2014 09:47:02
img_Show(hndl,iImage2) ;
// if(file_Exists("WF2.wav"))
snd_BufSize(3);
snd_Volume(127);
file_PlayWAV("WF16k.wav");
while(snd_Playing());
// else
// putstr("WF2.wav not found");
//endif
pause(7000);
case (char == 'B')
pause(7000);
// Image3 1.0 generated 22/08/2014 09:47:16
// putstr(" THREE");
// com_Init(combuffer, 2, 0); // reset buffer
case (char == 'C')
// Image4 1.0 generated 22/08/2014 09:47:47
img_Show(hndl,iImage4);
// media_Imge(0, 3) ;// show image
pause(1000);
snd_BufSize(3);
snd_Volume(127);
file_PlayWAV("Bubble16k.wav"); //WF16k.wav");
while(snd_Playing());
case (char == 'D')
for (frame := 0; frame <= 47; frame++)
pause(1);
next
pause(7000);
case (char == 'P')
gfx_Cls() ;
/*
pause(3000);
serout('A');//to(COM0); putch('5'); //
pause(3000);
case (char == '6')
numx := 50 ;
case (char == '7')
numx := 100 ;
*/
default:
endswitch
txt_MoveCursor(3,1);
print("Buffered ", ( com1_Count() )); // show count of chars in buffer
wend
pause(1000);
// Image4 1.0 generated 05/01/2014 15:03:59
/*
// Thermometer1 1.1 generated 16/11/2013 21:22:31
media_SetAdd(iThermometer1H, iThermometer1L) ; // point to the Thermometer1 image
media_VideoFrame(0, 0, numx) ; // where numx is 0 to 100 (for a displayed 50 to 150)
if (numx == 0)
dir := 1 ;
else if (numx == 100)
dir := -1 ;
endif
numx += dir ;
pause(10) ;
//putstr(" Idle");
*/
until ( com1_Full() || com1_Error() ); // reset if error occurred
forever
endfunc
"
Thanks,
Eyall
In the following code the button iWinbutton isnt working, only seen graphicaly, the state flag is stuck in ' 0 '. it looks like the Repeat/Forever loop isnt working.
The first repeat is before "state := touch_Get(TOUCH_STATUS);" and the associate forever is at the end, before endfunc. so why it isnt looping?
The code:
"
#platform "uLCD-43PT"
#inherit "4DGL_16bitColours.fnc"
#inherit "VisualConst.inc"
#inherit "DiExMonitorConst.inc"
#inherit "PrintDiskGoldelox.inc"
#inherit "LedDigitsDisplayGoldelox.inc"
var combuf[24]; // 24 vars = 48 bytes
var combuffer[1]; // 24 vars = 48 bytes
var page ;
func main()
var chr,char, e, e2, n, frame, state;
var numx, dir, colr, redo, numt, Wbs1, i, x, y ;
e := 0;
e2 := 0;
gfx_Set(SCREEN_MODE,LANDSCAPE) ;
gfx_Set(CONTRAST,5) ;
txt_Set(TEXT_OPACITY, OPAQUE);
numx := 0 ;
//com1_Reset();
// Uncomment the following if uSD images used.
// putstr("Mounting...\n");
if (!(disk:=file_Mount()))
while(!(disk :=file_Mount()))
// putstr("Drive not mounted...");
pause(200);
gfx_Cls();
pause(200);
wend
endif
gfx_TransparentColour(0x0020);
gfx_Transparency(ON);
pin_Set(OUTPUT, AUDIO_ENABLE);
pin_HI(AUDIO_ENABLE);
hndl := file_LoadImageControl("DIEXMO~1.dat", "DIEXMO~1.gci", 1);
// image1 1.0 generated 30/05/2014 11:38:29
//img_Show(hndl,iimage1) ;
// pause(5000);
if(file_Exists("bl16k.wav"))
snd_BufSize(3);
snd_Volume(127);
file_PlayWAV("bl16k.wav");
while(snd_Playing());
else
putstr("bl16k.wav not found");
endif
if(file_Exists("intro1.wav"))
snd_BufSize(3);
snd_Volume(127);
file_PlayWAV("intro1.wav");
while(snd_Playing());
else
putstr("intro1.wav not found");
endif
*/
// gfx_Set(OUTLINE_COLOUR, DARKOLIVEGREEN); // set outline colour, gfx_Cls() will draw outline
// gfx_Cls();
// Image5 1.0 generated 26/08/2014 23:28:47
//img_Show(hndl,iImage5) ;
// Winbutton1 1.0 generated 26/08/2014 23:51:14
img_ClearAttributes(hndl, iWinbutton1, I_TOUCH_DISABLE); // set to enable touch, only need to do this once
img_Show(hndl, iWinbutton1); // show button, only do this once
print("State 0"); // print initial state
touch_Set(TOUCH_ENABLE); // enable touch detection
// gfx_Cls();
repeat
state := touch_Get(TOUCH_STATUS); //get touch screen status
n := img_Touched(hndl,iWinbutton1);
//---------------------------------------------------------------------------
if(state == TOUCH_PRESSED) //if there's a press
if(n == iWinbutton1) //and if it's inside the button
img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, 1); //change state to state 1
img_Show(hndl, iWinbutton1); //show button
gfx_MoveTo(0,0); //move origin to point (0,0)
print("State 1"); //print state
endif
endif
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
if(state == TOUCH_RELEASED) //if there's a release
if(n == iWinbutton1) //and if it's inside the button
img_SetWord(hndl, iWinbutton1, IMAGE_INDEX,0); //change state to state 0
img_Show(hndl, iWinbutton1); //show button
gfx_MoveTo(0,0); //move origin to point (0,0)
print("State 0"); //print state
endif
endif
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
if(state == TOUCH_MOVING) //if there's movement
if(n == iWinbutton1) //and if it's inside the button
img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, 1); //change state to state 1
img_Show(hndl, iWinbutton1); //show button
gfx_MoveTo(0,0); //move origin to point (0,0)
print("State 1"); //print state
else //if movement is outside the button
img_SetWord(hndl, iWinbutton1, IMAGE_INDEX, 0); //change state to state 0
img_Show(hndl, iWinbutton1); //show button
gfx_MoveTo(0,0); //move origin to point (0,0)
print("State 0"); //print state
endif
endif
//----------------------------------------------------------------------------
repeat
// setbaud(BAUD_9600); // 9600 baud comms
com_SetBaud(COM1,960);
com1_Init(combuf, 48, 0); // set up a comms circular buffer, use the entire buffer, no sync character
repeat
sys_SetTimer(TIMER0, 2000); // set delay so we stay in next loop for 5 seconds
// wait for a while gathering bytes
// and continuously displaying the count
// of characters in the buffer.
//// repeat
// Video1 1.0 generated 16/11/2013 18:32:51
// txt_MoveCursor(2,1); // reset cursor to line 3, column 2
// print("Buffered ", [DEC2Z] ( com_Count() )); // show count of chars in buffer
until (! sys_GetTimer(TIMER0)); // loop until TIME_OUT register is 0
/*
if (com_Full())
txt_MoveCursor(3,1); // reset cursor to line 5, column 2
print("Buffer Full ", (++e) ); // print error count
endif
if (com_Error())
txt_MoveCursor(4,1); // reset cursor to line 7, column 2
print("Comms Error ", (++e2) ); // print error count
endif
*/
// now dump whatever we got to the terminal
while ( (char := serin1()) >= 0)
// txt_Set(TEXT_COLOUR, RED);
gfx_MoveTo(0,0);
// print("\n'",[CHR]char,"' is ");
to(COM1); putch(char); // send buffered chars to com port
//wend
/*
txt_Set(FONT_ID, 0);
txt_MoveCursor(0,1); // reset cursor to line 1, column 2
putstr("Serial Echo\n9600 baud");
*/
switch
case (char == 'A')
// Image2 1.0 generated 22/08/2014 09:47:02
img_Show(hndl,iImage2) ;
// if(file_Exists("WF2.wav"))
snd_BufSize(3);
snd_Volume(127);
file_PlayWAV("WF16k.wav");
while(snd_Playing());
// else
// putstr("WF2.wav not found");
//endif
pause(7000);
case (char == 'B')
pause(7000);
// Image3 1.0 generated 22/08/2014 09:47:16
// putstr(" THREE");
// com_Init(combuffer, 2, 0); // reset buffer
case (char == 'C')
// Image4 1.0 generated 22/08/2014 09:47:47
img_Show(hndl,iImage4);
// media_Imge(0, 3) ;// show image
pause(1000);
snd_BufSize(3);
snd_Volume(127);
file_PlayWAV("Bubble16k.wav"); //WF16k.wav");
while(snd_Playing());
case (char == 'D')
for (frame := 0; frame <= 47; frame++)
pause(1);
next
pause(7000);
case (char == 'P')
gfx_Cls() ;
/*
pause(3000);
serout('A');//to(COM0); putch('5'); //
pause(3000);
case (char == '6')
numx := 50 ;
case (char == '7')
numx := 100 ;
*/
default:
endswitch
txt_MoveCursor(3,1);
print("Buffered ", ( com1_Count() )); // show count of chars in buffer
wend
pause(1000);
// Image4 1.0 generated 05/01/2014 15:03:59
/*
// Thermometer1 1.1 generated 16/11/2013 21:22:31
media_SetAdd(iThermometer1H, iThermometer1L) ; // point to the Thermometer1 image
media_VideoFrame(0, 0, numx) ; // where numx is 0 to 100 (for a displayed 50 to 150)
if (numx == 0)
dir := 1 ;
else if (numx == 100)
dir := -1 ;
endif
numx += dir ;
pause(10) ;
//putstr(" Idle");
*/
until ( com1_Full() || com1_Error() ); // reset if error occurred
forever
endfunc
"
Thanks,
Eyall
Comment