wasp-os: MicroPython for PineTime!
#71
Hi Daniel and hi everyone,

back in early 2020 I managed to write some watchfaces (wasp-faces) working with wasp-os. In June I managed to "migrate" to wasp-os 0.2. Ever since I have not been successful trying to migrate them to wasp-os 0.3 (the current "stable" version, I think?). Thing is, I am completely stuck now and can't get anything to run. Usually I checked Daniel's commits since the last time compatible to my wasp-faces. This time, I simply do not know where to start (but believe me I have tried a lot).

If I follow the instructions I put down in spring (for wasp-faces) (slightly adapted below to meet 0.3 wasp-os standards), this happens:

Code:
$ wasp-os/tools/wasptool --exec wasp-faces/watchfaces/chrono24.py --eval "wasp.system.register(Chrono24App())" --console
Traceback (most recent call last):
  File "wasp-os/tools/wasptool", line 279, in <module>
    console = pexpect.spawn(pynus, encoding='UTF-8')
  File "/usr/lib/python3.8/site-packages/pexpect/pty_spawn.py", line 205, in __init__
    self._spawn(command, args, preexec_fn, dimensions)
  File "/usr/lib/python3.8/site-packages/pexpect/pty_spawn.py", line 276, in _spawn
    raise ExceptionPexpect('The command was not found or was not ' +
pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: wasp-os/tools/pynus/pynus.py.

So, if anyone in here feels like pointing me where to look (or giving it a try themself), I'd be very thankful. As you might notice, I don't do software development in my main time (let alone hardware stuff).

Cheers,
David
#72
(10-18-2020, 06:56 PM)purlupar Wrote: Hi Daniel and hi everyone,

back in early 2020 I managed to write some watchfaces (wasp-faces) working with wasp-os. In June I managed to "migrate" to wasp-os 0.2. Ever since I have not been successful trying to migrate them to wasp-os 0.3 (the current "stable" version, I think?). Thing is, I am completely stuck now and can't get anything to run. Usually I checked Daniel's commits since the last time compatible to my wasp-faces. This time, I simply do not know where to start (but believe me I have tried a lot).

There hasn't been a 0.3 released yet, but the current master branch is close to what 0.3 will be. It is essentially feature complete and the next round of changes are likely to be non-functional changes (updating the installer for newer PineTime releases).

Certainly the master branch is in fairly good shape at the moment.

(10-18-2020, 06:56 PM)purlupar Wrote: If I follow the instructions I put down in spring (for wasp-faces) (slightly adapted below to meet 0.3 wasp-os standards), this happens:

Code:
$ wasp-os/tools/wasptool --exec wasp-faces/watchfaces/chrono24.py --eval "wasp.system.register(Chrono24App())" --console
Traceback (most recent call last):
  File "wasp-os/tools/wasptool", line 279, in <module>
    console = pexpect.spawn(pynus, encoding='UTF-8')
  File "/usr/lib/python3.8/site-packages/pexpect/pty_spawn.py", line 205, in __init__
    self._spawn(command, args, preexec_fn, dimensions)
  File "/usr/lib/python3.8/site-packages/pexpect/pty_spawn.py", line 276, in _spawn
    raise ExceptionPexpect('The command was not found or was not ' +
pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: wasp-os/tools/pynus/pynus.py.

So, if anyone in here feels like pointing me where to look (or giving it a try themself), I'd be very thankful. As you might notice, I don't do software development in my main time (let alone hardware stuff).

This means you cannot execute the BLE terminal program (in a file called wasp-os/tools/pynus/pynus.py ) and based on the error message it doesn't appear to be installed. Did you run `make submodules` (from the build guide)? If that doesn't help then take a look in the wasp-os/tools/pynus folder and share what you see (including the result of a `git status`).

BTW if you have licensed the watch faces the same way was the rest of wasp-os then you're welcome to make a pull request to get them included in the main wasp-os repo. I'd be particularly keen to integrate the analogue clock faces (I like the other clock too... but am not yet decided on what fonts to include in the distro by default... I'm open to discussion though).
PineTime: wasp-os and MicroPython, Pinebook Pro:  Debian Bullseye
#73
(10-19-2020, 03:35 AM)danielt Wrote: BTW if you have licensed the watch faces the same way was the rest of wasp-os then you're welcome to make a pull request to get them included in the main wasp-os repo. I'd be particularly keen to integrate the analogue clock faces (I like the other clock too... but am not yet decided on what fonts to include in the distro by default... I'm open to discussion though).

This sounds exactly right! I understand you should add me as a collaborator so that I can create a branch. My github username is purlupar.
#74
At the moment I'm currently trying to work on my own watchface. Is there any chance there could be a very basic tutorial on that?
#75
(10-19-2020, 05:24 AM)purlupar Wrote: This sounds exactly right! I understand you should add me as a collaborator so that I can create a branch. My github username is purlupar.

There's not usually any admin needed from my side ahead of time.

Basically if you fork the wasp-os repo, add your app to the repo and get the app hooked up on the simulator and commit then you're pretty much there. At that point it's just a pull request away: https://docs.github.com/en/free-pro-team...rom-a-fork .

(10-19-2020, 08:33 AM)tomthetaffer Wrote: At the moment I'm currently trying to work on my own watchface. Is there any chance there could be a very basic tutorial on that?

There's not a specific watchface tutorial but there is the application programmer's guide which will show you how to write a simple "hello world" program and load it into the simulator and to a real watch.

Once you're happy with that adding a watch face is just a matter of copying clock.py (which excluding the two big comments that go into the reference manual is only 80 lines of code) and using the reference manual to look up any API calls you are not familiar with.

Any problems with the documentation then let me know. I'm always keen to improve.

PS Someone did ask for better comment in clock.py the other day and I've got some ideas to make it cleaner and easier to read... however even without clean ups it is still fairly short and simple.
PineTime: wasp-os and MicroPython, Pinebook Pro:  Debian Bullseye
#76
(10-19-2020, 02:11 PM)danielt Wrote:
(10-19-2020, 05:24 AM)purlupar Wrote: This sounds exactly right! I understand you should add me as a collaborator so that I can create a branch. My github username is purlupar.

There's not usually any admin needed from my side ahead of time.

Basically if you fork the wasp-os repo, add your app to the repo and get the app hooked up on the simulator and commit then you're pretty much there. At that point it's just a pull request away: https://docs.github.com/en/free-pro-team...rom-a-fork .

I see -- done that now. Exciting. :-)

Now, I can't succeed to get it running on the simulator or the watch, which is why I originally posted here (2 or 3 posts above this). This happens in the simulator:


Code:
>>> from apps.chrono import ChronoApp
>>> wasp.system.register(ChronoApp())
>>> wasp.system.run()
Watch is running, use Ctrl-C to stop
PWM.__init__(0, <machine.Pin object at 0x7fafe8eae160>) {'freq': 'FREQ_16MHZ', 'duty': 25, 'period': 16000}
PWM.init() {}
PWM.deinit() {}
MOTOR: set on
Traceback (most recent call last):
  File "/home/david/PineTime/wasp-os/wasp/wasp.py", line 389, in run
    self._tick()
  File "/home/david/PineTime/wasp-os/wasp/wasp.py", line 349, in _tick
    self._handle_touch(event)
  File "/home/david/PineTime/wasp-os/wasp/wasp.py", line 319, in _handle_touch
    self.app.touch(event)
  File "/home/david/PineTime/wasp-os/wasp/apps/launcher.py", line 58, in touch
    wasp.system.switch(app)
  File "/home/david/PineTime/wasp-os/wasp/wasp.py", line 174, in switch
    app.foreground()
  File "/home/david/PineTime/wasp-os/wasp/apps/chrono.py", line 65, in foreground
    self.draw(effect)
  File "/home/david/PineTime/wasp-os/wasp/apps/chrono.py", line 166, in draw
    self.ringM()
  File "/home/david/PineTime/wasp-os/wasp/apps/chrono.py", line 130, in ringM
    self.mark((120, 120), gry, 50, 112, 1, 120, 5, 0, 600)
  File "/home/david/PineTime/wasp-os/wasp/apps/chrono.py", line 88, in mark
    d.fill(c, int(z[0]+co*p-w//2), int(z[1]+si*p-w//2), int(w), int(w))
  File "/home/david/PineTime/wasp-os/wasp/draw565.py", line 138, in fill
    display.set_window(x, y, w, h)
  File "/home/david/PineTime/wasp-os/wasp/drivers/st7789.py", line 131, in set_window
    self.write_data(bytearray([y >> 8, y & 0xff, yp >> 8, yp & 0xff]))
ValueError: byte must be in range(0, 256)
#77
(10-20-2020, 03:18 PM)purlupar Wrote: Now, I can't succeed to get it running on the simulator or the watch, which is why I originally posted here (2 or 3 posts above this). This happens in the simulator:


Code:
>>> from apps.chrono import ChronoApp
>>> wasp.system.register(ChronoApp())
>>> wasp.system.run()
Watch is running, use Ctrl-C to stop
PWM.__init__(0, <machine.Pin object at 0x7fafe8eae160>) {'freq': 'FREQ_16MHZ', 'duty': 25, 'period': 16000}
PWM.init() {}
PWM.deinit() {}
MOTOR: set on
Traceback (most recent call last):
  File "/home/david/PineTime/wasp-os/wasp/wasp.py", line 389, in run
    self._tick()
  File "/home/david/PineTime/wasp-os/wasp/wasp.py", line 349, in _tick
    self._handle_touch(event)
  File "/home/david/PineTime/wasp-os/wasp/wasp.py", line 319, in _handle_touch
    self.app.touch(event)
  File "/home/david/PineTime/wasp-os/wasp/apps/launcher.py", line 58, in touch
    wasp.system.switch(app)
  File "/home/david/PineTime/wasp-os/wasp/wasp.py", line 174, in switch
    app.foreground()
  File "/home/david/PineTime/wasp-os/wasp/apps/chrono.py", line 65, in foreground
    self.draw(effect)
  File "/home/david/PineTime/wasp-os/wasp/apps/chrono.py", line 166, in draw
    self.ringM()
  File "/home/david/PineTime/wasp-os/wasp/apps/chrono.py", line 130, in ringM
    self.mark((120, 120), gry, 50, 112, 1, 120, 5, 0, 600)
  File "/home/david/PineTime/wasp-os/wasp/apps/chrono.py", line 88, in mark
    d.fill(c, int(z[0]+co*p-w//2), int(z[1]+si*p-w//2), int(w), int(w))
  File "/home/david/PineTime/wasp-os/wasp/draw565.py", line 138, in fill
    display.set_window(x, y, w, h)
  File "/home/david/PineTime/wasp-os/wasp/drivers/st7789.py", line 131, in set_window
    self.write_data(bytearray([y >> 8, y & 0xff, yp >> 8, yp & 0xff]))
ValueError: byte must be in range(0, 256)

I suspect that int(z[1]+si*p-w//2) has evaluated to a negative number (resulting in one of the four expressions on the last line being out of range). When running on the simulator it should be easy to print them: perhaps modify the set_window() method to print out all its arguments.

It will be a slow but it should be fairly clear.
PineTime: wasp-os and MicroPython, Pinebook Pro:  Debian Bullseye
#78
Is there any way we can use a linebreak? I tried using /n last night in a simple helloworld app, and the symbol printed as '?'.
#79
(10-21-2020, 02:38 AM)tomthetaffer Wrote: Is there any way we can use a linebreak? I tried using /n last night in a simple helloworld app, and the symbol printed as '?'.

Line break handling is integrated into the code to wrap text to fit a specified width. The assumption is that if you need to handle line breaks then you probably don't know how many characters are in the string so therefore you need to split it into lines.

Documentation for the line wrapping code is here (the wrap logic knows the currently selected font so no need to pass this as an argument):
https://wasp-os.readthedocs.io/en/latest...aw565.wrap

You can see the wrap() method being used for real in the pager application but the example in the self test is more compact and easier to read:
https://github.com/daniel-thompson/wasp-...pp.py#L154

Note that the testapp is also "cheating" a little since it knows that the string fits on the screen. Part of the reason the pager is so much more complex is that it allows us to scroll through the whole message regardless of length. Anyhow I'd suggest your first implementation be fairly simple (only show the first two/three lines of the notificaton) to get things working. You can add scrolling later to step through the message on the clock face if you like or alternatively you can just preview the first lines of the first message and keep the existing swipe-down approach to view and dismiss the notification.
PineTime: wasp-os and MicroPython, Pinebook Pro:  Debian Bullseye
#80
(10-21-2020, 02:00 AM)danielt Wrote: I suspect that int(z[1]+si*p-w//2) has evaluated to a negative number (resulting in one of the four expressions on the last line being out of range). When running on the simulator it should be easy to print them: perhaps modify the set_window() method to print out all its arguments.

It will be a slow but it should be fairly clear.

That was it! In fact, not negative but too large. I somehow wanted to draw hands larger than the display, which went well until now. I'll commit and re-do the pull request later today. Thanks so much!


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pinetime - Kids with special needs hidara 0 552 06-11-2024, 10:42 PM
Last Post: hidara
  Develop a new firmware for PineTime belushi 2 1,992 09-25-2023, 12:32 PM
Last Post: ccchan234
  Bluetooth BLE-MIDI-controller app for PineTime / InfiniTime Luno 0 885 08-20-2023, 05:17 AM
Last Post: Luno
  Zephyr Backlight Examples for PineTime lcj 0 1,064 05-06-2023, 02:54 PM
Last Post: lcj
  Zephyr is ready for pinetime jandy 1 2,690 05-06-2023, 02:15 PM
Last Post: lcj
  Send a message from Android to pinetime via BLE razrosman 0 1,263 11-05-2022, 08:24 AM
Last Post: razrosman
  PineTime Stuck in DFU Mode Eesha Barua 1 2,636 07-25-2022, 09:17 PM
Last Post: heyhewmike
  Idle tracking with PineTime: how versatile it is? schaman 1 2,141 07-13-2022, 12:50 AM
Last Post: wibble
  PineTime implemented with partial of pebble API jandy 0 1,879 03-20-2022, 08:58 PM
Last Post: jandy
  "Pine64 USB JTAG Adapter + OpenOCD + PineTime" should it work? ITCactus 4 4,915 03-02-2022, 05:58 AM
Last Post: wibble

Forum Jump:


Users browsing this thread: 5 Guest(s)