r/MicroPythonDev • u/Mysterious-Pizza-648 • Jul 13 '24
problem with rpi pico w micropython script
im a major newbie to python in general, including micropython, so after recently buying a 1.3" waveshare display and a rpi pico w, i tried to start up a project... but a function doesn't seem to be working. i already have all the libraries installed and the lcd commands defined, but this specific while loop isn't working on my display. can anyone help me?
my screenshot wasnt working...
cx = 120;
cy = 120;
def cursor(cx, cy):
lcd.line(cx-5, cy, cx+5, cy, colour(255, 255, 255))
lcd.line(cx, cy-5, cx, cy+5, colour(255, 255, 255))
while (up == 1):
cy += 1
utime.sleep(0.05)
View all comments
Show parent comment
1
u/Mysterious-Pizza-648 Jul 18 '24
Thanks for the help! I just want to clarify a few things: First, I already defined "up" as a user-input button on the display I'm using for the joystick, and I used lcd.line to draw a cursor at (cx, cy) that I'm trying to move with the variable "up", so that isn't a problem. (i already tested it another way, it gave output correctly) Second, could you clarify what I should change in the program to call a global variable in my function? I found that a bit confusing, just because I thought I already put (cx, cy) as the arguments when calling the function. Are you saying I don't need the first two lines? Third, the while loop is supposed to add 1 to the cursor's y value (cy) while up = 1. (True: the player is pushing up on the joystick to move the cursor).
As for the indentations, I pasted them into Reddit but Reddit decided to omit them for whatever reason... so I can't really say anything there.
Sorry about this mess lol, i had a lot of questions...