|
MHVLib
20111227
An efficiency oriented runtime library for AVR microcontrollers
|
00001 /* Copyright (c) 2011, Make, Hack, Void Inc 00002 * All rights reserved. 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions are met: 00006 * * Redistributions of source code must retain the above copyright 00007 * notice, this list of conditions and the following disclaimer. 00008 * * Redistributions in binary form must reproduce the above copyright 00009 * notice, this list of conditions and the following disclaimer in the 00010 * documentation and/or other materials provided with the distribution. 00011 * * Neither the name of the Make, Hack, Void nor the 00012 * names of its contributors may be used to endorse or promote products 00013 * derived from this software without specific prior written permission. 00014 * 00015 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00016 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00017 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00018 * DISCLAIMED. IN NO EVENT SHALL MAKE, HACK, VOID BE LIABLE FOR ANY 00019 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00020 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00021 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00022 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00024 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 */ 00026 00027 #ifndef MHV_WS2801_H_ 00028 #define MHV_WS2801_H_ 00029 00030 #define MHV_RGB_ORDER 5 00031 #include <MHV_RGB.h> 00032 #include <MHV_GammaCorrect.h> 00033 00034 // Squelch warnings about MHV_SHIFT_WRITECLOCK & MHV_SHIFT_WRITEDATA being undefined 00035 #ifndef MHV_SHIFT_WRITECLOCK 00036 #define MHV_SHIFT_WRITECLOCK 00037 #define MHV_SHIFT_WRITEDATA 00038 #endif 00039 #include <MHV_Shifter.h> 00040 00048 #define MHV_WS2801_CREATE(__mhvObjectName,__mhvLength) \ 00049 MHV_RGB __mhvObjectName ## _Buffer[__mhvLength]; \ 00050 MHV_SHIFTER_CLOCKED_RISING_CREATE(__mhvObjectName ## _Shifter); \ 00051 MHV_WS2801 __mhvObjectName(__mhvObjectName ## _Buffer, __mhvLength, __mhvObjectName ## _Shifter); 00052 00053 class MHV_WS2801 { 00054 private: 00055 uint16_t _length; 00056 MHV_RGB *_data; 00057 00058 MHV_Shifter &_shifter; 00059 00060 public: 00061 MHV_WS2801(MHV_RGB buf[], uint16_t length, MHV_Shifter &shifter); 00062 void setPixel(uint16_t pixel, uint8_t red, uint8_t green, uint8_t blue); 00063 void setPixel(uint16_t pixel, MHV_RGB *value); 00064 void setAll(uint8_t red, uint8_t green, uint8_t blue); 00065 void setAll(MHV_RGB *value); 00066 void setPixelGamma(uint16_t pixel, uint8_t red, uint8_t green, uint8_t blue); 00067 void setPixelGamma(uint16_t pixel, MHV_RGB *value); 00068 void setAllGamma(uint8_t red, uint8_t green, uint8_t blue); 00069 void setAllGamma(MHV_RGB *value); 00070 void rotate(bool forwards); 00071 void flush(); 00072 00073 }; 00074 00075 #endif /* MHV_WS2801_H_ */