Enter short text


Author Message
rea23
Newbie

Joined: 16/09/2022
Location: Switzerland
Posts: 26
Posted: 03:59pm 03 Dec 2022      

I made the circuit with a 10k potentiometer and R1k to 3.3 V and R1k to AGND. A button from wiper to ground is inserted. The setting of the letters works fine. But the transfer in the name always results in "?". Something in the program is terribly wrong and my old brain can't find the error.


' ***************************************
' Text input with poti (TimD and phil99)
' ADC0, 1k-10k-1k gives (measured):
' 0.2790...3.0080 V over poti
' Switch down on lower R1k: 0.0130 V
' Poti works ok ==> shows A...Z
' Newname shows ??? instead
'****************************************

SetPin GP26, AIN                      'ADC0 at pin31

' !! inverted colors because of "false" driver for LCD!! Take RGB values
CONST black_= RGB(255,255,255)        'black inv.
CONST green_= RGB(255,127,255)        'green inv.
CONST yellow_= RGB(0,0,255)           'yellow inv.

dim letter as string length 1         'letter for name
dim newname as string

newname = ""

cls black_                            'display black, iRGB of (0,0,0)
box 0,0,320,240,1, yellow_
FONT 2, 1

Again:
do
 mvolt=int(1000*pin(31))             'millivolt
 diff=3008-279                       'measured min/max
 du=diff/25                          '26-1 between
 u=int(mvolt/du)-1                   'first # should be 1
 letter=chr$(u+64)                   'A is chr$(65)
 text 4, 100, "Letter is: " + letter,,2,, yellow_, black_  'is ok, A...Z
 pause 100
loop until mvolt < 220                'leave the loop

Take:
newname = newname + letter            '??? only, letter lost
text 4, 16, "New name is: " + newname,,2,, yellow_, black_
goto Again

'How to save the name? ===> long press
end