Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <wiringpi.h>
- #include <wiringPiSPI.h>
- #include <softPwm.h>
- #include <bool.h>
- //declare global booleans and variables.
- #define button = true;
- void button_thread() {
- while(){
- //Detect buttons change booleans and values.
- //Update screen.
- }
- }
- int main(int argc, char *argv[]) {
- printf("Initializing setup...\n");
- // start bridge SPI
- // set SPI channel to 0 and speed to 16MHz
- if (wiringPiSPISetup(0, 16000000) < 0) {
- fprintf(stderr, "Could not setup WiringPi SPI.\n", sterror (errno));
- exit(1);
- }
- // start wiringpi setup
- if (wiringPiSetup() < 0) {
- fprintf(stderr, "Could not setup WiringPi.\n", sterror (errno));
- exit(1);
- }
- printf("Starting... \n");
- pinMode(13, INPUT); //MISO will use pin 13
- pinMode(1, OUTPUT); //GPIO1 will be used for PWM (analog output)
- uint8_t mosi[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- uint8_t miso[10] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
- // define I/O
- // define lcd
- // start thread buttons and switches.
- while(1) {
- //receive data
- wiringPiSPIDataRW(0, miso, 10); //SPI transfer to transfer 10 bits to the miso list.
- //effect function
- //if (button) {
- // miso = distortion();
- //}
- printf("Data received: " + miso + "\n");
- //output
- int data = miso[2] + ((miso[1] & 0x0F) << 8); //MISO value represented in percentage for PWM
- //unsure about this equation but will know more about the input we receive when we do some testing.
- // softPwmWrite(1, data);
- miso = mosi; //reset miso to be all 0's again.
- }
- return 0;
- }
- uint8_t distortion() {
- //individual functions for each effect for clean code
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement