andrewm@0: /* andrewm@0: * Utilities.h andrewm@0: * andrewm@0: * Created on: Oct 27, 2014 andrewm@0: * Author: parallels andrewm@0: */ andrewm@0: andrewm@0: #ifndef UTILITIES_H_ andrewm@0: #define UTILITIES_H_ andrewm@0: andrewm@13: extern int gNumAudioChannels; // How many audio channels are present andrewm@13: extern int gNumMatrixChannels; // How many matrix channels are present andrewm@13: andrewm@5: // Macros for accessing the matrix values: usable _only_ within render() andrewm@5: andrewm@5: // Read an analog input from input pin p at frame f andrewm@13: #define analogRead(p, f) (matrixIn[(f)*gNumMatrixChannels + (p)]) andrewm@5: // Write an analog output frame at output pin p, frame f, to value v giuliomoro@18: #define analogWriteFrame(p, f, v) (matrixOut[(f)*gNumMatrixChannels + (p)] = (v)) giuliomoro@18: #define analogWrite(pin, frame, value) \ giuliomoro@18: (({do {\ giuliomoro@18: for (int _privateI=(frame); _privateI>(bit))&1) giuliomoro@16: #define changeBit(word,bit,value) ((clearBit((word),(bit))) | ((value)<<(bit))) giuliomoro@16: //matrixGpio API: giuliomoro@18: #define setDigitalDirectionFrame(pin,frame,direction) matrixGpio[(frame)]=changeBit(matrixGpio[(frame)],(pin),(direction)) giuliomoro@18: #define setDigitalDirection(pin,frame,direction) (for(int _privateI=(frame);_privateI