Devnol / ShiftRegister74HC595-Pico

Port of the ShiftRegister74HC595 library to the Raspberry Pi Pico
Other
2 stars 0 forks source link

Make library loadable like a normal Arduino IDE library #2

Open Gavin-Perry opened 5 months ago

Gavin-Perry commented 5 months ago

I use PICOs and want a simple shifter for 595. This looks like the right library. Why can't I just install it from the library list in Arduino IDE? Why make it difficult?

Devnol commented 5 months ago

Clearly because I want you to suffer.

Jokes aside I didn't know you could list it on the Arduino library installer. Doesn't the regular arduino 74hc595 library work with the pico if through the ide it compiles arduino.h as well?

Gavin-Perry commented 5 months ago

I'm not sure what the problem is. I've tried a couple of shifter libraries with no luck. At this point I think I might have a bad pico because even blink doesn't work. Code loads but loop not working.

Thank you for the quick reply.

Gavin


From: Panos Koutsoumanis @.> Sent: Friday, May 24, 2024 5:57:08 PM To: Devnol/ShiftRegister74HC595-Pico @.> Cc: Gavin Perry @.>; Author @.> Subject: Re: [Devnol/ShiftRegister74HC595-Pico] Make library loadable like a normal Arduino IDE library (Issue #2)

Clearly because I want you to suffer.

Jokes aside I didn't know you could list it on the Arduino library installer. Doesn't the regular arduino 74hc595 library work with the pico if through the ide it compiles arduino.h as well?

— Reply to this email directly, view it on GitHubhttps://github.com/Devnol/ShiftRegister74HC595-Pico/issues/2#issuecomment-2130418381, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVR4PP545FLF7VNNETFU33TZD6ZTJAVCNFSM6AAAAABIIHRJUGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZQGQYTQMZYGE. You are receiving this because you authored the thread.Message ID: @.***>

Devnol commented 5 months ago

Well do confirm that your pico is working first of all but other than that if the Arduino IDE supports it then you should be able to compile the regular sn74hc595 lib for this. This fork is basically an exact copy of that except all Arduino.h calls have been replaced with the native pico c sdk

Gavin-Perry commented 2 months ago

Finally back to this project and I'm having trouble with your version Arduino IDE using pico board from earle philhower - https://github.com/earlephilhower/arduino-pico Being lazy I just copied the three source files into the existing library for a direct replacement. Do I need to do more?

I start with: ShiftRegister74HC595<2> sr(dataPin, clockPin, latchPin); // create a shift register pair <2> it complains: candidate expects 1 argument, 3 provided You want just 1 pin? I don't think I can align to a hardware SPI based on my board layout (already built) Which pin would it be? Doesn't look 100% compatible to me. The original seems to have timing issues and messes up pins on the second shift register sometimes. I'm pretty sure I have it wired correctly.

Here's the full error:

C:\Users\CPSLab\Documents\OdorChoiceDev\Pico Code\ShiftTestPico\ShiftTestPico.ino:11:55: error: no matching function for call to 'ShiftRegister74HC595<2>::ShiftRegister74HC595(const int&, const int&, const int&)' 11 | ShiftRegister74HC595<2> sr(dataPin, clockPin, latchPin); // create a shift register pair <2> | ^ In file included from c:\Users\CPSLab\Documents\OdorChoiceDev\Pico Code\libraries\ShiftRegister74HC595\src/ShiftRegister74HC595.h:34, from C:\Users\CPSLab\Documents\OdorChoiceDev\Pico Code\ShiftTestPico\ShiftTestPico.ino:6: c:\Users\CPSLab\Documents\OdorChoiceDev\Pico Code\libraries\ShiftRegister74HC595\src/ShiftRegister74HC595.hpp:15:1: note: candidate: 'ShiftRegister74HC595::ShiftRegister74HC595(spi_inst_t, uint8_t, uint8_t, uint8_t) [with unsigned char Size = 2; spi_inst_t = spi_inst; uint8_t = unsigned char]' 15 | ShiftRegister74HC595::ShiftRegister74HC595(spi_inst_t spiPort, uint8_t sdiPin, uint8_t sckPin, uint8_t latchPin) | ^~~~~~ c:\Users\CPSLab\Documents\OdorChoiceDev\Pico Code\libraries\ShiftRegister74HC595\src/ShiftRegister74HC595.hpp:15:1: note: candidate expects 4 arguments, 3 provided c:\Users\CPSLab\Documents\OdorChoiceDev\Pico Code\libraries\ShiftRegister74HC595\src/ShiftRegister74HC595.h:14:7: note: candidate: 'constexpr ShiftRegister74HC595<2>::ShiftRegister74HC595(const ShiftRegister74HC595<2>&)' 14 | class ShiftRegister74HC595 | ^~~~~~~~ c:\Users\CPSLab\Documents\OdorChoiceDev\Pico Code\libraries\ShiftRegister74HC595\src/ShiftRegister74HC595.h:14:7: note: candidate expects 1 argument, 3 provided c:\Users\CPSLab\Documents\OdorChoiceDev\Pico Code\libraries\ShiftRegister74HC595\src/ShiftRegister74HC595.h:14:7: note: candidate: 'constexpr ShiftRegister74HC595<2>::ShiftRegister74HC595(ShiftRegister74HC595<2>&&)' c:\Users\CPSLab\Documents\OdorChoiceDev\Pico Code\libraries\ShiftRegister74HC595\src/ShiftRegister74HC595.h:14:7: note: candidate expects 1 argument, 3 provided

exit status 1

Gavin-Perry commented 2 months ago

Doh! I did have a wiring error! swapped RCLK and SRCLK between the 2 registers. After I fix that I'll see if the original library works, but my problem with 100% compatibility still stands.

Gavin-Perry commented 2 months ago

Maybe this is clear enough for it to be fixed Pico version declares in .h public: ShiftRegister74HC595(spi_inst_t *spiPort, uint8_t sdiPin, uint8_t sckPin, uint8_t latchPin); Why does pointer to spiPort make it only want one argument? using ShiftRegister74HC595<2> sr(dataPin, clockPin, latchPin); // create a shift register pair <2> produces this error candidate expects 1 argument, 3 provided

Original declaration public: ShiftRegister74HC595(const uint8_t serialDataPin, const uint8_t clockPin, const uint8_t latchPin); works just fine. Need to overload the declaration to allow both?

Devnol commented 2 months ago

It's been a loong time since I worked on this and I don't have any hardware near me to try but iirc the spiport argument just expects one of the spi ports as defined on the pico itself. (so either spi0 or spi1). Does the code from the example I have work?