sparkslabs/pyxie

Add support for analogRead/Write,map and Serial objects

sparkslabs opened this issue · 1 comments

Target is the desire to be able to write code that looks like this:

analogInPin = A0
analogOutPin = 9
sensorValue = 0
outputValue = 0
Serial.begin(9600)

while True:
    sensorValue = analogRead(analogInPin)
    outputValue = map(sensorValue, 0, 1023, 0, 255)
    analogWrite(analogOutPin, outputValue)
    Serial.print("sensor = ")
    Serial.print(sensorValue)
    Serial.print("\t output = ")
    Serial.println(outputValue)
    delay(2)

This requires the following:

  • Support for profile defined variables : A0
  • Support for profile defined objects : Serial with methods - begin, print, println, begin
  • Support for profile defined functions/function calls that return values : analogRead, map
  • analogWrite should currently work in this context, but needs checking.

Support for profile defined variables : A0

  • Done. (0.1.23)
    Support for profile defined objects : Serial with methods - begin, print, println, begin
  • Done. (0.1.23)
    Support for profile defined functions/function calls that return values : analogRead, map
  • Done (0.1.23)
    analogWrite compiles correctly (0.1.23)

Also, from (0.1.23) release notes:

Arduino Support

Specific set of functionality checked/added in this release:

  • Serial support - .begin(), .print(), .println()
  • constrain
  • map
  • random, randomSeed
  • analogWrite
  • analogRead
  • millis
  • Support for constants/ids : A0-A7, HIGH, LOW, INPUT, OUTPUT

This is in addition to other previous functionality like: Servos, Digital IO, time delays, etc