Announcement

Collapse
No announcement yet.

some problems with my alarm clock

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • some problems with my alarm clock

    hi guys, i have a little problem with my alarm clock programm.
    i have to give out 4 figures like this 12:34. so i try it in this way:

    - i store the value of the buttons in a buffer with the str_PutByte - command
    - and read them out with the str_GetByte - command
    and the problem is that he always overwrite the first figure and don't move on!

    what i need is, that the first value (the first button i push) is the first figure, the second value is the second figure ...and when i push more than 4 times it have to jump back on the first possision.
    i hope it was not to hard to understand, here a little example of my code:

    func sendkey()
    txt_Set(TEXT_OPACITY, OPAQUE);
    txt_Set(TEXT_COLOUR, WHITE);
    txt_Set(FONT_SIZE , FONT3);
    txt_MoveCursor(20, 5);

    var uhrzeit[4] ;
    s:=0;

    while(s 20&&x50&&y 80&&x50&&y 140&&x50&&y

  • #2


    Not sure why you are trying to do it the way you are (using a character array to hold bytes), but if you shange the code around a bit like the below, the example you have given works fine.

    #platform "uLCD-32PT_GFX2"
    #inherit "4DGL_16bitColours.fnc"
    var uhrzeit[4] ;
    func sendkey()
    var s,p ;
    txt_Set(TEXT_OPACITY, OPAQUE);
    txt_Set(TEXT_COLOUR, WHITE);
    txt_Set(FONT_SIZE , FONT3);
    txt_MoveCursor(20, 5);
    p:=str_Ptr(uhrzeit);
    s:=0;
    print (str_GetByte(p + s++)) ;
    print (str_GetByte(p + s++)) ;
    putstr(":");
    print (str_GetByte(p + s++)) ;
    print (str_GetByte(p + s++)) ;
    endfunc
    func main()
    var p,keyval;
    p:=str_Ptr(uhrzeit);
    keyval := 1;
    str_PutByte(p,keyval);
    keyval := 2;
    str_PutByte(p+1,keyval);
    keyval := 3;
    str_PutByte(p+2,keyval);
    sendkey() ;
    repeat forever
    endfunc
    Mark

    Comment


    • #3


      thanks for your answer,

      you're right it works fine but just for the numbers 1,2,3,4 the rest of the numbers won't be print (e.g. 09:58) and the cursor don't jump back to the first position if i push more than 4 times?!

      stricker

      Comment


      • #4


        There were some errors with your code that were fixed in my version.

        My code expands to prints as many digits as required and jumps back if commanded to without problems.
        Mark

        Comment

        Working...
        X