This is a Shield Bot Library
Fork of Shield_Bot_v12 by
Diff: ShieldBot_v12.h
- Revision:
- 1:1d96ab1dbcc4
- Parent:
- 0:7535295d1670
diff -r 7535295d1670 -r 1d96ab1dbcc4 ShieldBot_v12.h --- a/ShieldBot_v12.h Wed Sep 09 05:53:29 2015 +0000 +++ b/ShieldBot_v12.h Tue Sep 15 13:40:55 2015 +0000 @@ -1,23 +1,24 @@ -/** Color pixels library using WS2812B and nRF51822 (16Hz) - * It's for - * + http://www.seeedstudio.com/depot/Digital-RGB-LED-FlexiStrip-60-LED-1-Meter-p-1666.html - * + http://www.seeedstudio.com/depot/WS2812B-Digital-RGB-LED-Waterproof-FlexiStrip-144-LEDmeter-2-meter-p-1869.html - * + http://www.seeedstudio.com/depot/WS2812B-RGB-LED-with-Integrated-Driver-Chip-10-PCs-pack-p-1675.html +/* + * ShieldBot_v12.h + * A library for ShieldBot + * + * Copyright (c) 2015 seeed technology inc. + * Author : Jiankai.li + * Create Time: Sep 2015 + * Change Log : * * The MIT License (MIT) * - * Copyright (c) 2014 Seeed Technology Inc. - * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -27,19 +28,14 @@ * THE SOFTWARE. */ + +// ensure this library description is only included once + #ifndef __SHIELDBOT_V12_H__ #define __SHIELDBOT_V12_H__ #include <stdint.h> -typedef union { - uint32_t rgb; - struct { - uint8_t r; - uint8_t g; - uint8_t b; - }; -} color_t; /** Color pixels class using WS2812B and nRF51822 (16Hz) * @@ -59,53 +55,34 @@ * } * @endcode */ -class ColorPixels + +// library interface description +class Shieldbot { -public: - /** Initilaze - * \param pin number of GPIO - * \param num number of pixels - */ - ColorPixels(uint8_t pin, uint16_t num); - - ~ColorPixels(); - - /** Set the color of a pixel (without update) - * \param index index of a pixel - * \param r red - * \param g green - * \param b blue - */ - void set_color(uint16_t index, uint8_t r, uint8_t g, uint8_t b); - - void set_color(uint16_t index, uint32_t rgb); - - void set_all_color(uint8_t r, uint8_t g, uint8_t b); - - void rainbow(uint8_t r, uint8_t g, uint8_t b); - - void rainbow(uint32_t rgb = 0x0000FF); - - /** Update - */ - void update(); - - /** Turn off all pixels - */ - void clear(); - -private: - typedef union { - struct { - uint8_t g, r, b; - }; - uint32_t grb; - } grb_t; - - uint8_t pin; - uint16_t num; - grb_t *colors; + // user-accessible "public" interface + public: + Shieldbot(); + int readS1(); + int readS2(); + int readS3(); + int readS4(); + int readS5(); + void setMaxSpeed(int); + void setMaxSpeed(int, int); + void setMaxLeftSpeed(int); + void setMaxRightSpeed(int); + void rightMotor(signed char); + void leftMotor(signed char); + void drive(signed char, signed char); + void forward(); + void backward(); + void stop(); + void stopRight(); + void stopLeft(); + void fastStopLeft(); + void fastStopRight(); + void fastStop(); }; -#endif // __COLOR_PIXELS_H__ +#endif