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 - DarkGizmo

Pages: 1
1
Thumby / Re: Battery
« on: May 06, 2022, 06:42:56 PM »
Once again I answer my own post from a discord answer by JasonTC

Code: [Select]
import thumby
from machine import ADC

adc = ADC(26)

# Average when unplugged is around 3700
# Average when plugged is around 4000
charging_threshold = 38500
average_charging_value = adc.read_u16()

while True:
    thumby.display.fill(0)
   
    average_charging_value = (adc.read_u16() + average_charging_value) // 2
    if average_charging_value > charging_threshold:
        thumby.display.drawText("Charging", 0, 0, 1)
    else:
        thumby.display.drawText("Not charging", 0, 0, 1)
   
    thumby.display.update()

2
Thumby / Battery
« on: May 06, 2022, 11:34:04 AM »
I think I've read somewhere that the battery life can be up to 3-hours, but that depends on screen brigtness
What if we draw only a black screen with low brightness and make the thumby 1 FPS, could that extent to battery life to way more than 3 hours?

I've also read that the current battery status (low, medium, full) would maybe be exposed in a future update, is there a way to know if the thumby is plugged it right now?

3
Thumby / Re: Game Code Python Import
« on: May 04, 2022, 10:50:43 AM »
For those interested here's the solution I found:

Add this to you main file (Your __YOUR_GAME__.py file)
Code: [Select]
# Add Current Folder to Path
current_working_directory = "/".join(__file__.split("/")[0:-1])
sys.path.insert(1, current_working_directory)

current_working_directory will be "/Games/__YOUR_GAME__"
By inserting in sys.path the import should work even if they are in the current directory and not in the root


4
Thumby / Game Code Python Import
« on: May 03, 2022, 02:29:06 AM »
I've just received my Thumbies (!!!)
I wanted to import my game to it, but it doesn't run. I've been commenting code to figure out the issue and the first issue I see is importing game files.
I've split my code into multiple file and had no issue importing other files, but it seems I was running the files from the root, when I move my game to "/Games/Demo" instead of "/" my import don't work anymore

I've notice that if I change
"import game_framework" to "import Games.Demo.game_framework" it seems to fix the issue

But then when I want to change the name to something meaningful I'll have to go through all my files and swap the imports...

Is there some python code I don't know that might solve this issue?
Is there something I'm missing?
Or am is that simply a limitation of how the thumby/micropython works that I have to handle manually?

5
Thumby / Re: Thumby Code Editor Issues
« on: April 27, 2022, 03:07:23 PM »
I feel more and more that's it's an emulator issue, I keep listing my files every execution. Sometime a file is missing and just with code changes it reappears.

On the emulator page, there is a list of files, are all those file supposed to be accessible, because it seems to fit all my files that are set to emulate (the white checkmark). But not all of them are available when the emulator is started?

Anyone has any pointer for this issue? I'm thinking of migrating all my data to a python .py file so I don't have to fight this issue, but it just doesn't feel right

6
Thumby / Re: Thumby Code Editor Issues
« on: April 25, 2022, 11:06:34 PM »
I've created a empty main.py that only loads a file. Doesn't seem to work with my .spr file, but works with the same file if it's a .bin file.
Am I missing something? Is the extension part of my issue?

Code: [Select]
print("Open file")
with open("/player_idle_10x11_x2.spr",'rb') as animFile:
    print("hello")

Outputs:
>>> __import__('/main')
Open file
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/main.py", line 6, in <module>
OSError: [Errno 2] ENOENT

while

Code: [Select]
print("Open file")
with open("/player_idle_10x11_x2.bin",'rb') as animFile:
    print("hello")

Outputs:
>>> __import__('/main')
Open file
hello
<module '/main' from '/main.py'>

Same file content just the extension was changed

If I run os.listdir() I get a variable number of files depending of which file I have emulated or not

['animation.py',
'background.py',
'character.py',
'collectible_12x10_x18_sprite.bin',
'collision_manager.py',
'game_framework.py',
'key.py',
'labyrinth.py',
'lib',
'main.py',
'player.py',
'player_idle_10x11_x2_mask.bin']

if I remove from emulation this file "player_idle_10x11_x2_mask.bin", then I get this list, which seems to be all my files, except this one...-

['animation.py',
'background.py',
'character.py',
'collectible_12x10_x18_sprite.bin',
'collision_manager.py',
'game_framework.py',
'key.py',
'labyrinth.py',
'lib',
'main.py',
'player.py',
'player_idle_10x11_x2_sprite.bin',
'player_walk_10x11_x3_mask.bin',
'player_walk_10x11_x3_sprite.bin']

So my guess is renaming the file to .bin or .spr changes the order and affects the files somehow. Has anyone seen something like this? I'm not sure if I'm doing something wrong or something weird is happening outside of my control

7
Thumby / Re: Thumby Code Editor Issues
« on: April 25, 2022, 12:05:57 PM »
Make sure to check the white emulation box on the sprite data file and that it's path is where you expect (hover over the file tab)

Yes it should good, is there a limit on the number of character of a filename? Or a limit of file the emulator can support?

8
Thumby / Thumby Code Editor Issues
« on: April 24, 2022, 11:26:54 PM »
Hello everyone,

I haven't yet received my thumby, but I am already starting a project in the Thumby Code Editor

It's a great tool but I  have some questions that I couldn't find any answer online
I'm still learning Python after years of using C++, so maybe some of these are related to my lack of Python knowledge

  • I want to create a new file in my project, but can't seem to be able to add a new file, when  I import a file from PC, it switches the current tab to the new file, so I lose this particular file. Am I missing something? I have a work-around, but it is clearly a weird and convoluted way to add a new file to the project. I have a feeling it might be due to the fact that I work Thumby-less
  • I rather like working with binary files for my sprite data, but for some reason sometime the editor seems to lose a reference to one of my .bin file. I get "OSError: [Errno 2] ENOENT" on a line where I load the file. I made sure the file was there with the emulated check and it was. If I remove the line loading the file everything works and then later I can bring it back and it works. Then sometime later it might stop working with no change around this particular line or file or logic... I tried refreshing the Code Editor, but it didn't fix it
  • The import sprite tool is great and that's mostly what I used to create my sprite binary files. The Bitmap Builder is a quick and easy tool to use, but it seems both can't be used together and that's a shame. It'd be great to be able to import binary files, modify the data and then re-export in binary. Is that something that's being considered?
  • I might be missing something, but I haven't seen anything about outputting in the shell in the Code Editor? Without a debugger outputting to shell would be great, I've seen somewhere that you can write to file, but without an actual Thumby that doesn't seem to be feasible?

Thank you
I'm already having a great time and haven't received my Thumby yet. Can't wait to see how small it actually is!

Pages: 1
SMF spam blocked by CleanTalk