Program to resistive fabric network to detect ring seal on CPR mask. Uses feeback from neopixel LEDs to demonstrate secure seal. Uses NeoStrip library for NeoPixel methods and class.

Fork of NeoStrip by James Song

Committer:
dehrlich
Date:
Fri Dec 02 04:43:54 2016 +0000
Revision:
3:343fa1d679f7
Parent:
2:d607600a697d
no changes to NeoStrip library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aswild 0:9f237b11f0a8 1
aswild 0:9f237b11f0a8 2
aswild 0:9f237b11f0a8 3 #ifndef NEOSTRIP_H
aswild 0:9f237b11f0a8 4 #define NEOSTRIP_H
aswild 0:9f237b11f0a8 5
aswild 0:9f237b11f0a8 6 #ifndef TARGET_LPC1768
aswild 0:9f237b11f0a8 7 #error NeoStrip only supports the NXP LPC1768!
aswild 0:9f237b11f0a8 8 #endif
aswild 0:9f237b11f0a8 9
aswild 0:9f237b11f0a8 10 // NeoColor struct definition to hold 24 bit
aswild 0:9f237b11f0a8 11 // color data for each pixel, in GRB order
aswild 0:9f237b11f0a8 12 typedef struct _NeoColor
aswild 0:9f237b11f0a8 13 {
aswild 0:9f237b11f0a8 14 uint8_t green;
aswild 0:9f237b11f0a8 15 uint8_t red;
aswild 0:9f237b11f0a8 16 uint8_t blue;
aswild 0:9f237b11f0a8 17 } NeoColor;
aswild 0:9f237b11f0a8 18
aswild 0:9f237b11f0a8 19 /**
aswild 0:9f237b11f0a8 20 * NeoStrip objects manage the buffering and assigning of
aswild 0:9f237b11f0a8 21 * addressable NeoPixels
aswild 0:9f237b11f0a8 22 */
aswild 0:9f237b11f0a8 23 class NeoStrip
aswild 0:9f237b11f0a8 24 {
aswild 0:9f237b11f0a8 25 public:
aswild 0:9f237b11f0a8 26
aswild 0:9f237b11f0a8 27 /**
aswild 0:9f237b11f0a8 28 * Create a NeoStrip object
aswild 0:9f237b11f0a8 29 *
aswild 0:9f237b11f0a8 30 * @param pin The mbed data pin name
aswild 0:9f237b11f0a8 31 * @param N The number of pixels in the strip
aswild 0:9f237b11f0a8 32 */
aswild 0:9f237b11f0a8 33 NeoStrip(PinName pin, int N);
aswild 0:9f237b11f0a8 34
aswild 0:9f237b11f0a8 35 /**
aswild 0:9f237b11f0a8 36 * Set an overall brightness scale for the entire strip.
aswild 0:9f237b11f0a8 37 * When colors are set using setPixel(), they are scaled
aswild 0:9f237b11f0a8 38 * according to this brightness.
aswild 0:9f237b11f0a8 39 *
aswild 0:9f237b11f0a8 40 * Because NeoPixels are very bright and draw a lot of current,
aswild 0:9f237b11f0a8 41 * the brightness is set to 0.5 by default.
aswild 0:9f237b11f0a8 42 *
aswild 0:9f237b11f0a8 43 * @param bright The brightness scale between 0 and 1.0
aswild 0:9f237b11f0a8 44 */
aswild 0:9f237b11f0a8 45 void setBrightness(float bright);
aswild 0:9f237b11f0a8 46
aswild 0:9f237b11f0a8 47 /**
aswild 0:9f237b11f0a8 48 * Set a single pixel to the specified color.
aswild 0:9f237b11f0a8 49 *
aswild 0:9f237b11f0a8 50 * This method (and all other setPixel methods) uses modulo-N arithmetic
aswild 0:9f237b11f0a8 51 * when addressing pixels. If p >= N, the pixel address will wrap around.
aswild 0:9f237b11f0a8 52 *
aswild 0:9f237b11f0a8 53 * @param p The pixel number (starting at 0) to set
aswild 0:9f237b11f0a8 54 * @param color A 24-bit color packed into a single int,
aswild 0:9f237b11f0a8 55 * using standard hex color codes (e.g. 0xFF0000 is red)
aswild 0:9f237b11f0a8 56 */
aswild 0:9f237b11f0a8 57 void setPixel(int p, int color);
aswild 0:9f237b11f0a8 58
aswild 0:9f237b11f0a8 59 /**
aswild 0:9f237b11f0a8 60 * Set a single pixel to the specified color, with red, green, and blue
aswild 0:9f237b11f0a8 61 * values in separate arguments.
aswild 0:9f237b11f0a8 62 */
aswild 0:9f237b11f0a8 63 void setPixel(int p, uint8_t red, uint8_t green, uint8_t blue);
aswild 0:9f237b11f0a8 64
aswild 0:9f237b11f0a8 65 /**
aswild 0:9f237b11f0a8 66 * Set n pixels starting at pixel p.
aswild 0:9f237b11f0a8 67 *
aswild 0:9f237b11f0a8 68 * @param p The first pixel in the strip to set.
aswild 0:9f237b11f0a8 69 * @param n The number of pixels to set.
aswild 0:9f237b11f0a8 70 * @param colors An array of length n containing the 24-bit colors for each pixel
aswild 0:9f237b11f0a8 71 */
aswild 0:9f237b11f0a8 72 void setPixels(int p, int n, const int *colors);
aswild 0:9f237b11f0a8 73
aswild 0:9f237b11f0a8 74 /**
aswild 0:9f237b11f0a8 75 * Reset all pixels in the strip to be of (0x000000)
aswild 0:9f237b11f0a8 76 */
aswild 0:9f237b11f0a8 77 void clear();
aswild 0:9f237b11f0a8 78
aswild 0:9f237b11f0a8 79 /**
aswild 0:9f237b11f0a8 80 * Write the colors out to the strip; this method must be called
aswild 0:9f237b11f0a8 81 * to see any hardware effect.
aswild 0:9f237b11f0a8 82 *
aswild 0:9f237b11f0a8 83 * This function disables interrupts while the strip data is being sent,
aswild 0:9f237b11f0a8 84 * each pixel takes approximately 30us to send, plus a 50us reset pulse
aswild 0:9f237b11f0a8 85 * at the end.
aswild 0:9f237b11f0a8 86 */
aswild 0:9f237b11f0a8 87 void write();
jamesmsong 2:d607600a697d 88
jamesmsong 2:d607600a697d 89 void initialize();
jamesmsong 2:d607600a697d 90
jamesmsong 2:d607600a697d 91 void progress(float time);
aswild 0:9f237b11f0a8 92
aswild 0:9f237b11f0a8 93 protected:
aswild 0:9f237b11f0a8 94 NeoColor *strip; // pixel data buffer modified by setPixel() and used by neo_out()
aswild 0:9f237b11f0a8 95 int N; // the number of pixels in the strip
aswild 0:9f237b11f0a8 96 int Nbytes; // the number of bytes of pixel data (always N*3)
aswild 0:9f237b11f0a8 97 float bright; // the master strip brightness
aswild 0:9f237b11f0a8 98 gpio_t gpio; // gpio struct for initialization and getting register addresses
aswild 0:9f237b11f0a8 99 };
aswild 0:9f237b11f0a8 100
aswild 0:9f237b11f0a8 101 #endif
aswild 0:9f237b11f0a8 102
aswild 0:9f237b11f0a8 103