Recent Posts

21
 My intent was to download an entire season of the original MacGyver TV show as well as some 80's commercials along with the Ghostbusters movie or something. Does the default "TinyTVmode" resume all channels from where they left off after turning it off?   or does it just start all channels from the beginning and play them simultaneously upon restart?   If the latter is true that would make putting an entire season or long movie on the SD card kind of pointless I suppose as you would have to watch the entire thing in a single sitting before turning off and going back to the beginning again?   

I understand that would probably require some form of flash storage to remember a hashtag to resume and given the size of the device that might not be feasible.  It would be cool though to turn it on and not always see the same content starting again. 

I will always support companies like TinyCircuits and Adafruit.  I hope you continue making cool things.
22
Thumby / Re: Thumby development Discord server or something similar?
« Last post by Void777 on October 18, 2021, 07:54:07 PM »
Ive been wondering this as well. I was also thinking maybe a subreddit.
23
Thumby / Re: Thumby development Discord server or something similar?
« Last post by rli on October 18, 2021, 06:31:05 PM »
I'd be in favor of a simple Discord server as well, official or unofficial.

I know the TinyCircuits team is small and has a lot of responsibilities already so I'm not sure they want to tack on chatroom moderation to that.

@TinyCircuits, are you planning to create some sort of TinyCircuits Discord soon? If not, maybe we can create an unofficial one?
24
Thumby / Thumby development Discord server or something similar?
« Last post by CoolieCoolster on October 18, 2021, 05:21:37 PM »
While I've spent several hours over the past few days trying to figure out how the various functions of the various existing programs work, as I've made quite little progress in understanding why my implementations of the functions break so often, perhaps a Discord server (or some other real-time communication method) could be created to complement the forum? While I could ask each and every question here, not only would many of them be so insignificant as to be a waste of an entire thread, but the frequency at which I would have questions would lend itself more to a real-time form of communication, such as a Discord server. In addition to allowing developers to share projects and ideas with each other more easily, perhaps it could be expanded later on to include other Thumby-related channels?
25
Thumby / Re: Invader Test
« Last post by bkumanchik on October 18, 2021, 01:18:56 PM »
Will do, I will try to flesh this out into a real game if I have time, Can I see a screenshot of it running on the real hardware, I'd like to see the relative scale of things if possible.

Thanks,

Brian
26
Thumby / Re: Invader Test
« Last post by Ben Rose on October 18, 2021, 12:53:58 PM »
Very cool to see that you're able to work on this with the emulator!  I tested it on hardware quickly and it seems to work as intended, keep us updated if you do any more before you have hardware!
27
Thumby / Re: Is the Random Function broken for anyone else?
« Last post by Jason on October 18, 2021, 10:55:53 AM »
The random number returning the same number should happen both on hardware and in the emulator.

In the case of your game, a more reliable way to seed the random number generator is to feed
Code: [Select]
random.seed(seed) the passed time/ticks using
Code: [Select]
time.ticks_us() or
Code: [Select]
time.ticks_ms() after the user selects a character. It is unlikely that a user will select a character at the same milli or micro second each time (unless maybe they hold down the button from game start each time).
28
Thumby / Re: Extracting sprites from bitmap data?
« Last post by Jason on October 18, 2021, 10:46:38 AM »
The sprite arrays only define the pixels of the sprite, not any positional data.

The Thumby blit function allows you to draw sprites anywhere on the screen:
Code: [Select]
thumby.display.blit(bitmapData, x, y, width, height, key) where x and y are relative to the top-left of the screen at 0,0 (left to right is +x and top to bottom is +y) but I think you already know that.

One way to do this in a compact way is to make a function that takes a string and position and then draws/blits each character in the string to the screen based on the position. Each character's width would have to be accounted for too, unless it is monospaced and each character is the same width in which case you draw each character at the same offset from the last. We've done some testing and found that this is slow, now we're looking into building a smaller font into the firmware.
29
Thumby / Extracting sprites from bitmap data?
« Last post by CoolieCoolster on October 18, 2021, 01:38:20 AM »
As a means of learning one or two things about Python, I've begun to try implementing my calculator idea, hopefully one I can manage after a bit of trial and error despite my lacking Python abilities. As using the default font wouldn't allow me to fit nearly enough characters on screen at once, I added bitmaps for each of the 25 or so three pixel wide characters that could be used in an operation. While I considered just drawing all of these to the screen in addition to avoid having to take up extra space with a fullscreen bitmap, I realized that the text needed to add all the characters to the screen would eliminate any saved space. Therefore, I was wondering if there were a way to instead define sprites based on their coordinates in the 72x40 bitmap image, as it doesn't seem that coordinate data is directly included in the bitmap data, other than the fact that each column has its own entry for up to eight rows. If it's possible, I imagine not having the character set icons defined twice might save some space.

Attached is my latest "version" of NanoCalc, with nearly all graphics I intend to use included. Next I intend to try to figure out how to add in logic so that it knows which box is currently selected and flicker the white rectangle of that box, so if anyone has suggestions for that, that would also be appreciated!
30
Thumby / Re: Is the Random Function broken for anyone else?
« Last post by Void777 on October 17, 2021, 02:49:15 PM »
Do you have example code? I think I was able to reproduce the issue you're describing.

I believe the "problem" is that the random number generator's seed doesn't change between runs of the emulator.

Here's my test:
Code: [Select]
import random
import time

l = [0,1,2,3]

for i in range(20):
    r = random.choice(l)
    print(f"{i}: {r}")

# Outputs:
# 0: 1
# 1: 0
# 2: 1
# 3: 3
# 4: 0
# 5: 3
# 6: 3
# 7: 3
# 8: 1
# 9: 1
# 10: 3
# 11: 3
# 12: 3
# 13: 1
# 14: 1
# 15: 2
# 16: 1
# 17: 2
# 18: 3
# 19: 1

The output is the same each time.

Relevant documentation: https://docs.micropython.org/en/latest/library/random.html?highlight=random#random.seed

Some usual tricks for initializing a seed for less deterministic results is passing in the time, but because the emulator has no true Real Time Clock(RTC) or this MICROPY_PY_URANDOM_SEED_INIT_FUNC setting enabled, all the random number functions will act deterministically.

In practice, you might be fine with passing the time.ticks_ms() or time.ticks_us() as the seed (https://docs.micropython.org/en/latest/library/time.html?highlight=time#time.ticks_ms):
Code: [Select]
import random
import time

random.seed(time.ticks_us()) # Relies on minor inconsistencies to differ a little each time

l = [0,1,2,3]

for i in range(20):
    r = random.choice(l)
    print(f"{i}: {r}")

It's not great and depending on how early on in the execution you're getting random numbers, it might get the same seed more often than not.
I think your probably right, ill try and edit it based on your suggestions, Heres the code for the character select screen, which should select a random opponent based on the character id.
Code: [Select]
chars = [['goggles', goggles_icon, goggles_icon_selected], ['zap', zap_icon, zap_icon_selected], ['apex', apex_icon, apex_icon_selected]]
        for i in range(len(chars)):
            thumby.display.blit(box, (16*i) + 5, 0, 16, 16, 1)
            if i != selected:
                thumby.display.blit(chars[i][1], (16*i) + 5, 0, 16, 16, 1)
            else:
                thumby.display.blit(chars[i][2], (16*i) + 5, 0, 16, 16, 1)
        if thumby.buttonR.pressed() and selected < len(chars):
            selected += 1
        elif thumby.buttonL.pressed() and selected > 0:
            selected -= 1
        elif thumby.buttonA.pressed():
            selected_char = chars[selected][0]
            enemy_char_data = random.choice(chars)
            enemy_char = enemy_char_data[0]
            while enemy_char == selected_char:
                enemy_char_data = random.choice(chars)
                enemy_char = enemy_char_data[0]
            thumby.display.fill(1)
            select_screen = False
            singleplayer_battle(selected_char, enemy_char)
        time.sleep(0.1)
        thumby.display.update()
        i = 0
SMF spam blocked by CleanTalk