Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Windows Vista

Pages: 1
1
Thumby / Error while trying to send data through link cable
« on: April 26, 2022, 03:36:21 PM »
I just want to confirm that this error means I'm just trying to send too much at once over the link cable?

"Link message size out of bounds: 833"

Thanks for the help!

2
Thumby / Re: Checking Battery Voltage, MicroPython
« on: April 05, 2022, 03:42:01 PM »
That's exciting to hear. It's always a bummer when it randomly just shuts down  ;D

3
Thumby / Checking Battery Voltage, MicroPython
« on: April 01, 2022, 11:44:24 AM »
I was trying to convert this code I grabbed from the Discord from Arduino C/C++ to MicroPython:

Quote
JasonTC — 03/22/2022
It is possible to check the battery voltage. The battery is connected on ADC0/GPIO26 to a voltage divider.

I don't have anything in MicroPython, but here's some Arduino C/C++ code someone else wrote:
float total = 0.0f;
const int numberSamples = 25;

for(int i=0; i<numberSamples; i++){
  float battVoltage = analogRead(A0);
  battVoltage = 2.0 * 3.3 * battVoltage / (4095.0);
  battVoltage = (int) (battVoltage * 100.0 + 0.5) / 100.0;
  total += battVoltage;
}

Serial.print("Battery: ");
Serial.println(total/numberSamples);

I'm trying to switch it over to MicroPython:
Code: [Select]
adc = ADC(26)
battVoltage = 1.0
numberSamples = 25

while(1):
    total = 0
    for int in range (0, numberSamples):
        thumby.display.fill(0)
        battVoltage = adc.read_u16()
        battVoltage = 2.0 * 3.3 * battVoltage / (4095.0)
        battVoltage = (battVoltage * 100.0 + 0.5) / 100.0
        total = battVoltage + total
        thumby.display.update()
       
    thumby.display.fill(0)
    thumby.display.drawText("Battery:", 1, 1, 1)
    thumby.display.drawText(str(total/numberSamples), 1, 11, 1)
    battVoltage = adc.read_u16()
    thumby.display.drawText(str(battVoltage), 1, 21, 1)
    thumby.display.update()   
    time.sleep(2)

I'm not exactly sure that the math translates from Arduino C/C++ code to MicroPython. I think the value from "battVoltage = adc.read_u16()"  might be throwing me off? I'm not sure exactly what is going on with the math. This is the first time I'm trying to interact with a pin too.  So I'm not sure if I'm 100% sure doing that right either :P
I've exhausted my google-fu.
If anyone has any info/advise on battery math or things I might be able to google to set me on the right path, that would be cool. :D

4
Thumby / Thumby Care
« on: April 01, 2022, 10:32:05 AM »
Will things like leaving it connected to the editor and just unplugging it without disconnecting or turning it off first damage it?
Or vice versa, leaving it on then plugging it in to the computer and connecting it to the editor?
Is there anything I might not realize or think about, as someone that's not used to working with things like this on a normal basis?
How often do I water it?  ;)


5
Thumby / Re: Sprite not being completely mirrored?
« on: November 08, 2021, 11:40:46 AM »
That's cool, I was just worried I was missing something basic :D
Thanks for the response!

6
Thumby / Sprite not being completely mirrored?
« on: November 06, 2021, 11:57:01 PM »
Please see attached screenshot.  In the screenshot, the two feet of the monster sprite, on the right, aren't mirrored.
I'm trying to mirror this sprite but it's only mirroring most of it. What did I miss or am doing wrong?

# BITMAP: width: 20, height: 27
evilMon_sprite = (0,0,0,128,192,64,200,152,48,32,0,0,16,152,72,76,64,128,0,0,
           0,128,6,31,16,18,22,16,27,14,0,228,143,8,8,9,10,15,128,0,
           0,10,7,2,2,2,0,32,50,22,20,20,51,32,2,2,2,7,10,0,
           0,0,0,0,0,0,0,0,7,4,4,0,7,4,4,0,0,0,0,0)

thumby.display.drawSprite(evilMon_sprite, 25, 0, 20, 27, 1, 0, 0)

Thanks for your time!

Pages: 1
SMF spam blocked by CleanTalk