Search found 19 matches

by twodoctors
Mon Aug 08, 2022 7:19 am
Forum: General Discussion and Questions
Topic: Problem with exec(open(filename).read())
Replies: 8
Views: 4534

Re: Problem with exec(open(filename).read())

Roberthh wrote:
Mon Aug 08, 2022 5:59 am
In that case the code and the data it requires is simply too large and cannot be handled by a Pi Pico.
Perhaps so. The same code works for my other programme but it was driving a 2004 LCD screen. Tht 240x240 pixels are probably a bit too much.

Oh well....
by twodoctors
Mon Aug 08, 2022 12:04 am
Forum: General Discussion and Questions
Topic: Problem with exec(open(filename).read())
Replies: 8
Views: 4534

Re: Problem with exec(open(filename).read())

So a bit more googling reminds me that 115200 bytes happens to be 240x240 pixels x 2-byte colour = 115200 bytes. I think the framebuffer is full with the launcher programme, and can't load another programme as there's no room.

So how do I flush the framebuffer?
by twodoctors
Sun Aug 07, 2022 11:27 pm
Forum: General Discussion and Questions
Topic: Problem with exec(open(filename).read())
Replies: 8
Views: 4534

Re: Problem with exec(open(filename).read())

Why not importing the module and having a function to start and stop the functionality? I'm try to create a launcher so I can run all mini games and programmes without plugging into a pc. LI would look for an error in the file_launcher code. I'll do more test and see what's gone wrong. I've used th...
by twodoctors
Sun Aug 07, 2022 2:24 am
Forum: General Discussion and Questions
Topic: Problem with exec(open(filename).read())
Replies: 8
Views: 4534

Problem with exec(open(filename).read())

Hi all, I'm back with more problems! I've trying to write a file_launcher programme so I can open different programmes with my Pi Pico using a 1.3" LCD screen. I'm getting memory allocation error when trying to launch my files. I don't think my code in the file_launcher is crucial, but this is the c...
by twodoctors
Thu Jul 21, 2022 11:03 pm
Forum: General Discussion and Questions
Topic: Traffic lights with a button interrupt - how would you have done it?
Replies: 12
Views: 9811

Re: Traffic lights with a button interrupt - how would you have done it?

I understand the "def sleep():" and how I could have saved lines and lines of codes if the traffic green time is long. I don't understand your FSM approach. if event == EVT_STOP: state = STAT_END red = false green = false Is that both red and green off? Traffic lights don't behave like that. I think...
by twodoctors
Thu Jul 21, 2022 2:56 pm
Forum: General Discussion and Questions
Topic: Traffic lights with a button interrupt - how would you have done it?
Replies: 12
Views: 9811

Traffic lights with a button interrupt - how would you have done it?

Hi all, Just playing with my Pico and practising doing some codes without looking up stuff. Thought I would tackle something "simple" like a traffic light sequence. I expanded it to a pedestrian crossing lights as well. And to make it even more complex, I added a pedestrian request button so that it...
by twodoctors
Wed Jul 13, 2022 3:19 pm
Forum: General Discussion and Questions
Topic: How do I "dynamically" name my servo?
Replies: 10
Views: 5814

Re: How do I "dynamically" name my servo?

You put me to shame Olivier! :lol: I won't show you my code then! Twodoctors be pound of your code. The secret to code is to follow PEP20 - Zen of Python and those two steps: Make it work Improve it Let us know if you want help to understand OOP . Thanks Olivier. Yourself and Jimmo (and other helpe...
by twodoctors
Tue Jul 12, 2022 1:01 am
Forum: General Discussion and Questions
Topic: How do I "dynamically" name my servo?
Replies: 10
Views: 5814

Re: How do I "dynamically" name my servo?

I've started a project MicroPython-ShootingGallery , I plan to use it for archery training. You can see it on develop branch. It's just the beginning. You create Target(servo_pin, hide_duty_ns, show_duty_ns) , then you add target to ShootingGallery . You put me to shame Olivier! :lol: I won't show ...
by twodoctors
Tue Jul 12, 2022 12:56 am
Forum: General Discussion and Questions
Topic: How do I "dynamically" name my servo?
Replies: 10
Views: 5814

Re: How do I "dynamically" name my servo?

jimmo wrote:
Mon Jul 11, 2022 10:45 am
twodoctors wrote:
Mon Jul 11, 2022 10:42 am
Giving this error
CODE: SELECT ALL

AttributeError: 'PWM' object has no attribute 'duty_16'
duty_16 should be duty_u16
:o

Spent an hour trying to work out why it didn't work. 🤦🏻‍♂️
by twodoctors
Mon Jul 11, 2022 10:42 am
Forum: General Discussion and Questions
Topic: How do I "dynamically" name my servo?
Replies: 10
Views: 5814

Re: How do I "dynamically" name my servo?

I've worked it out by trial and error. I'm sure someone will have an even more elegant solution to this. So for some reason this doesn't work: count_target = range(len(targets)) for t in count_target: target_servos = choice(targets) #target_servos.duty_16(4500)# targets.remove(target_servos) utime.s...