Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:26 28 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : [PicoMite] aliases

Author Message
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 07:09am 03 Jul 2023
Copy link to clipboard 
Print this post

Hi!

I'm new to PicoMite, and I started to write a 1D pong game like this one.

I implemented most of the game, simulating it on the console; next step will be to attach a WS2812.

I have a question: is it possible to define aliases, to point to GPIOs? Like:

DIM GAME_LED_PIN = GP2

which does not work...

Thanks,

Frédéric

PS : I have to say that PicoMite is awesome! There is even more batteries included than in Micropython! The fact that I can connect to a board through minicom, and start coding without any external tool reminds me my Amstrad CPC  
I will surely propose to my students to use it for they projects, as they can't spend too much time in coding, and they often mess up C/C++ code...
Frédéric
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9129
Posted: 07:23am 03 Jul 2023
Copy link to clipboard 
Print this post

Welcome to the forum

You can do it like this

DIM GAME_LED_PIN = MM.INFO(PINNO GP2)
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 08:12am 03 Jul 2023
Copy link to clipboard 
Print this post

Welcome, fmffma :)

You mention using a WS2812. If it's  single one, fitted to a Pico clone board, then it will almost certainly be a type O and not the type B usually found in strips. These single ones can be used like this:

BITBANG WS2812 O, <pin_number>, 1, RGB(<red_value>, <green_value>, <blue_value>

I usually find them too bright if using, for example, RGB(red). RGB(60,0,0) is far more bearable. :)

The manual shows how to use a string of them.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 08:36am 03 Jul 2023
Copy link to clipboard 
Print this post

  matherp said  Welcome to the forum

You can do it like this

DIM GAME_LED_PIN = MM.INFO(PINNO GP2)

Ok, I see. Thank you!
Frédéric
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 08:39am 03 Jul 2023
Copy link to clipboard 
Print this post

  Mixtel90 said  Welcome, fmffma :)

You mention using a WS2812. If it's  single one, fitted to a Pico clone board, then it will almost certainly be a type O and not the type B usually found in strips. These single ones can be used like this:

BITBANG WS2812 O, <pin_number>, 1, RGB(<red_value>, <green_value>, <blue_value>

I usually find them too bright if using, for example, RGB(red). RGB(60,0,0) is far more bearable. :)

The manual shows how to use a string of them.

I will use a strip, so I guess it is type B. But I note your comment for onboard RGB LEDs.

Thanks!
Frédéric
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 12:02pm 03 Jul 2023
Copy link to clipboard 
Print this post

If using a strip just beware...
They are actually 5V devices and are not guaranteed to work at 3V3. Also, the 3V3 supply from the PicoMite is from a switching power supply with a maximum output of about 300mA. That's only five LEDs at full brightness - and you may not manage that. Also, the logic level for the first LED is, according to spec, too high to work with a 3V3 input. A very neat way to get round this is to power the first LED from 5V via a silicon diode. That drops its supply voltage and, as the high logic level is a percentage of that, it brings it into range of a 3V3 input (a series resistor of 1k or so is recommended). The rest of the string should be powered from 5V as usual.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 05:30pm 03 Jul 2023
Copy link to clipboard 
Print this post

Yes, the strip has its own power supply.

About the levels, I'm not sure to understand the issue with the first LED...

We used this strip for the big sign at the entrance of our hackerspace , and I'm pretty sure it was driven with an ESP8266, which is also 3.3V rated. It was working fine.

I'm about to test it, I'll let you know how it goes.

Thanks,
Frédéric
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 07:51pm 03 Jul 2023
Copy link to clipboard 
Print this post

The LEd strip works fine
Frédéric
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 09:10pm 03 Jul 2023
Copy link to clipboard 
Print this post

Good. :)
They often do work, but according to the spec for the WS2812B they shouldn't. :)

Input voltage high is a minimum of 0.7 x VDD. If VDD is 5v then Vhigh = 3.5V. In theory a 3V3 input won't switch them on. Powering the first LED at 5 - 0.6 = 4.4V makes Vhigh 3.08V which is just nice. If you can fit a diode in it's belt and braces - guaranteed to work.

Data sheet
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
fmafma

Newbie

Joined: 30/06/2023
Location: France
Posts: 31
Posted: 05:08am 04 Jul 2023
Copy link to clipboard 
Print this post

Ok, I understand the first LED trick.
Frédéric
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 06:11am 04 Jul 2023
Copy link to clipboard 
Print this post

Yep. Powering the first LED from 3V3 also works, but it's a bit less useful as the first one then has to be on the PCB with the 3V3 supply (or run an extra wire). With a bit of fiddling you can fit the diode on the strip, although you are now powering it at the second LED rather than the first. For shortish strips you can just power the lot via a diode to keep things easy. I like easy. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024