Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Clue Unix Fix #304

Merged
merged 15 commits into from
Apr 9, 2020
Merged

Clue Unix Fix #304

merged 15 commits into from
Apr 9, 2020

Conversation

andreamah
Copy link
Contributor

@andreamah andreamah commented Apr 8, 2020

Description:

Clue simulator should work on Ubuntu with these changes 🛫🚀

Issue:

On UNIX systems, the large base64 image string would be split up when being sent to the front-end. To fix this, the front-end will collect incomplete messages and add them to the beginning of incoming new messages to see if they work there.

For this to work, it relies on the fact that the child process triggered by process_user_code.py only sends JSON-formatted strings to stdout. Fortunately, process_user_code.py already re-formats print strings in JSON before sending them to the frontend.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Limitations:

Please describe limitations of this PR

Testing:

Used mega-test from #290 , but I ran on Ubuntu.
NOTE: this test needs some slideshow bmp photos in the current working directory!

from adafruit_bitmap_font import bitmap_font

from adafruit_clue import clue
from datetime import datetime
import time

from adafruit_slideshow import SlideShow, PlayBackDirection, PlayBackOrder
import board

# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(
    board.DISPLAY,
    dwell=1,
    folder=".",
    loop=True,
    fade_effect=False,
    auto_advance=True,
    order=PlayBackOrder.ALPHABETICAL,
    direction=PlayBackDirection.FORWARD,
)

for i in range(2):
    slideshow.advance()
    

clue_data = clue.simple_text_display(title="Clue Sensor Data!", title_scale=2,)

val = 100
for i in range(12):
    val += 1
    clue_data.show_terminal()
    time.sleep(0.5)
    print(val)
    print(f"time {datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]}")

    print(clue_data.text_group.hidden)
for i in range(10):
    val += 1
    clue_data[0].text = "Accelerometer:"
    clue_data[1].text = "Gyro:"
    clue_data[2].text = "Magnetic:"
    clue_data[3].text = "Pressure: {:.3f} hPa".format(val)
    clue_data[4].text = "Altitude: {:.1f} m".format(val)
    clue_data[5].text = "Temperature: {:.1f} C".format(val)
    clue_data[6].text = "Humidity: {:.1f} %".format(val)
    clue_data[7].text = "Proximity: {}".format(val)
    clue_data[8].text = "Gesture: {}".format("flip")
    clue_data.text_group.hidden = False
    clue_data[9].text = "Color: R: {} G: {} B: {} C: {}".format(100, 100, 100, 100)
    clue_data[10].text = "Button A: {}".format(False)
    clue_data[11].text = "Button B: {}".format(False)
    clue_data[12].text = "Touch 0: {}".format(False)
    clue_data[13].text = "Touch 1: {}".format(False)
    
    # clue_data.text_group.hidden = False
    clue_data[14].text = "Touch 2: {}".format(False)
    clue_data.show()
    print("shouldn't show until the end")
    time.sleep(0.5)
    print(clue_data.text_group.hidden)
# Create the slideshow object that plays through once alphabetically.
slideshow = SlideShow(
    board.DISPLAY,
    dwell=1,
    folder=".",
    loop=True,
    fade_effect=False,
    auto_advance=True,
    order=PlayBackOrder.ALPHABETICAL,
    direction=PlayBackDirection.FORWARD,
)
print(clue_data.text_group.hidden)
for i in range(2):
    slideshow.advance()

# clue_data.show_terminal()

Checklist:

  • My code follows the style guidelines of this project
  • My code has been formatted with npm run format and passes the checks in npm run check
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

src/extension.ts Outdated Show resolved Hide resolved
@xnkevinnguyen
Copy link
Contributor

Confirmed tested on MAC

@andreamah andreamah changed the title WIP: UNIX FIX Clue Unix Fix Apr 8, 2020
Copy link
Contributor

@vandyliu vandyliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@xnkevinnguyen xnkevinnguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Awesome fix, as always. Is it possible to add a comment where we say that this part is necessary for unix systems? Someone in the future might code in windows and remove it not knowing it's necessary

Copy link

@nasadigital nasadigital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch (again)!
LGTM

src/extension.ts Outdated Show resolved Hide resolved
@andreamah andreamah merged commit d7d924a into dev Apr 9, 2020
@andreamah andreamah deleted the users/t-anmah/clue-unix-fix branch April 9, 2020 00:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants