Libraries to Update for the Photon

@Hotaman, there is a purpose for the checks in the regular GPIO wiring functions. Having the fast_pin functions available gives advanced programmers an extra toolset they can use beyond that. The Photon's pin mapping does not lend itself to whole-port operations and digitalWriteFast() uses pinSetFast/PinResetFast to do a single command regardless of the target pin state. It is assumed that pinMode() was used prior to using the fast_pin functions.

I believe you are referring to an Arduino register which is not present in the STM32. Furthermore, the GPIO architecture on the STM32 is different. There are several registers in the STM32 for setting a pin's mode. Can you explain a scenario where fast pinMode() is required?

1 Like

Has anyone successfully run the plotly library on the Photon, I tried the version from the Web IDE and that hangs the Photon while the version on github.com seems to work but the data doesnā€™t appear in the plotly gridā€¦

Hi, Iā€™m trying to get started with my Dotstar LEDs and my photon but I have no idea what is going wrong. Iā€™m using sn74hct125n for level shifting. I want to use hw-spi but in the linrary git@github.com:technobly/SparkCore-DotStar.git the pin mapping of the sw-spi was brocken so Iā€™ve modified the pin mapping with this:

+#if PLATFORM_ID == 0 // Core
+  #define pinLO(_pin) (PIN_MAP[_pin].gpio_peripheral->BRR = PIN_MAP[_pin].gpio_pin)
+  #define pinHI(_pin) (PIN_MAP[_pin].gpio_peripheral->BSRR = PIN_MAP[_pin].gpio_pin)
+#elif PLATFORM_ID == 6 // Photon
+  STM32_Pin_Info* PIN_MAP2 = HAL_Pin_Map(); // Pointer required for highest access speed
+  #define pinLO(_pin) (PIN_MAP2[_pin].gpio_peripheral->BSRRH = PIN_MAP2[_pin].gpio_pin)
+  #define pinHI(_pin) (PIN_MAP2[_pin].gpio_peripheral->BSRRL = PIN_MAP2[_pin].gpio_pin)
+#else
+  #error "*** PLATFORM_ID not supported by this library. PLATFORM should be Core or Photon ***"
+#endif
 // fast pin access
-#define pinLO(_pin) (PIN_MAP[_pin].gpio_peripheral->BRR = PIN_MAP[_pin].gpio_pin)
-#define pinHI(_pin) (PIN_MAP[_pin].gpio_peripheral->BSRR = PIN_MAP[_pin].gpio_pin)

now it compiles. But nothing happens. I hope someone can help me.

Ah by the way the way the Dotstar library of the web ide needs an update.

@StuttVoll,

did you connect to the correct data pin that is defined?

Iā€™m using hardware spi -> A3 for clock and A5 for data. correct?

@StuttVoll,

it is defined in firmware - https://github.com/technobly/SparkCore-DotStar/blob/master/firmware/examples/1-strandtest.cpp#L43

Change it to suit your project and test again?

Sorry for being to unclear I#ve modified the Example too. To use the hardware spi Iā€™ve killed all pin settings in the strandtest but with using the define port for using hw spi doesnā€™t change anything.

After some rebuilds and reflashing the stripe is filling itself up with white color and the speed is something like every second. The filling start at various positions on different starts of the system. This leads me to the thinking it is coupled with clock. Iā€™ve programmed somthing with more speed and colors.

@StuttVoli, I didnā€™t use any libs with my DotStar setup. i rolled my own code and found some interesting behavior. Iā€™m driving a 1m strip directly off the Particle pin and it works great. You must set every led on the strip or you will get white on the led after the last one you set due to the end frame being all 1ā€™s.

@Hotaman is there a public example of your project? With this perhaps I can fix the library because the community library in the web ide has the map problem too earlier mentioned in this thread for software spi. Thanks

@Dick @boldbigflank Hey folks, Iā€™m also trying to resurrect WarSting on the Photon!

Iā€™m building a ā€œWarBlasterā€ from a Nintendo Zapper. I got it mostly done during a live workshop session that I havenā€™t made public, because I ran into some code incompatibilities when trying to flash the old code; once thatā€™s resolved, Iā€™ll do a new VWorkshop to help publicize the Star Wars challenge. :slight_smile:

Hereā€™s the video from that session, so you can see what Iā€™m talking aboutā€¦

Anyway, I tried resolving the errors, but to no avail; any chance you know how to update the code so the IDE will flash it to my little Photon?

Cheers :slight_smile:

@alexhack The warsting wifiscan library is not necessary any more, check out my pull request which is a start to remove that and use the newer built-in wifi scanning capabilities of the latest firmware.

1 Like

Woohoo, thanks! Iā€™ll give it a try.

I would have to suggest IRremote (with working IRrecv)

Iā€™m having trouble using Servo , as done in the reference documentation, on my photon.
In the documentation, the Servo in ā€œServo myservo;ā€ is blue, like int is when typed, its being recognized as a special thing (Iā€™m quite a beginner, not to familiar with the terminology, and am not sure what else to call the special thing). When I tried using servos like this, and like I have on Arduino previously, and try to verify the code, I get an error saying that the ā€œServo myservo;ā€ is me trying to define a function, and it canā€™t happen there.

That is a very very minimal description. If you could elaborate on what your issues are, weā€™d have a better idea what youā€™re facing or how we could help. Saying: ā€œit doesnā€™t workā€ is not that usefulā€¦

Just copy past the original error message, that makes more sense to us than a somewhat confusing reworded version of it.
And providing your code (if it's not too long) would help too.

BTW:

That would be a "keyword" or a "reserved word/term" I'd guess.

Hmm. I tried verifying a slightly modified version of my code today and it is working fine:

Servo myservo;

int servoPin = D0;

void setup() {
    myservo.attach(servoPin);
}

void loop() {
    myservo.write(120);
    delay(1000);
    myservo.write(0);
    delay(1000);
}

(I know this is about as basic as it gets, Iā€™m just trying to familiarize myself with the photon)

Iā€™m sorry for any inconvenience I may have caused. Thank you for your friendliness.

No worries :+1: