├── Firmware ├── version.txt ├── Source │ └── bakebit_v1.0.0 │ │ ├── FastLED-FastLED3.1 │ │ ├── fastspi_dma.h │ │ ├── .gitignore │ │ ├── extras │ │ │ ├── RainbowDemo.bin.zip │ │ │ ├── AppleII.s65 │ │ │ └── RainbowDemo.s65 │ │ ├── platforms │ │ │ ├── arm │ │ │ │ ├── d21 │ │ │ │ │ ├── fastled_arm_d21.h │ │ │ │ │ ├── led_sysdefs_arm_d21.h │ │ │ │ │ └── clockless_arm_d21.h │ │ │ │ ├── kl26 │ │ │ │ │ ├── fastled_arm_kl26.h │ │ │ │ │ ├── led_sysdefs_arm_kl26.h │ │ │ │ │ └── clockless_arm_kl26.h │ │ │ │ ├── stm32 │ │ │ │ │ ├── fastled_arm_stm32.h │ │ │ │ │ └── led_sysdefs_arm_stm32.h │ │ │ │ ├── nrf51 │ │ │ │ │ ├── fastled_arm_nrf51.h │ │ │ │ │ ├── led_sysdefs_arm_nrf51.h │ │ │ │ │ └── clockless_arm_nrf51.h │ │ │ │ ├── sam │ │ │ │ │ ├── fastled_arm_sam.h │ │ │ │ │ └── led_sysdefs_arm_sam.h │ │ │ │ └── k20 │ │ │ │ │ ├── fastled_arm_k20.h │ │ │ │ │ ├── led_sysdefs_arm_k20.h │ │ │ │ │ ├── smartmatrix_t3.h │ │ │ │ │ └── octows2811_controller.h │ │ │ └── avr │ │ │ │ ├── fastled_avr.h │ │ │ │ └── led_sysdefs_avr.h │ │ ├── docs │ │ │ └── mainpage.dox │ │ ├── library.properties │ │ ├── platforms.h │ │ ├── preview_changes.txt │ │ ├── examples │ │ │ ├── Multiple │ │ │ │ ├── OctoWS2811Demo │ │ │ │ │ └── OctoWS2811Demo.ino │ │ │ │ ├── MultipleStripsInOneArray │ │ │ │ │ └── MultipleStripsInOneArray.ino │ │ │ │ ├── ArrayOfLedArrays │ │ │ │ │ └── ArrayOfLedArrays.ino │ │ │ │ ├── MirroringSample │ │ │ │ │ └── MirroringSample.ino │ │ │ │ ├── ParallelOutputDemo │ │ │ │ │ └── ParallelOutputDemo.ino │ │ │ │ └── MultiArrays │ │ │ │ │ └── MultiArrays.ino │ │ │ ├── Blink │ │ │ │ └── Blink.ino │ │ │ ├── Cylon │ │ │ │ └── Cylon.ino │ │ │ ├── AnalogOutput │ │ │ │ └── AnalogOutput.ino │ │ │ ├── NoisePlayground │ │ │ │ └── NoisePlayground.ino │ │ │ ├── Pintest │ │ │ │ └── Pintest.ino │ │ │ ├── RGBCalibrate │ │ │ │ └── RGBCalibrate.ino │ │ │ ├── ColorTemperature │ │ │ │ └── ColorTemperature.ino │ │ │ ├── FirstLight │ │ │ │ └── FirstLight.ino │ │ │ ├── Noise │ │ │ │ └── Noise.ino │ │ │ ├── Fire2012 │ │ │ │ └── Fire2012.ino │ │ │ ├── DemoReel100 │ │ │ │ └── DemoReel100.ino │ │ │ └── SmartMatrix │ │ │ │ └── SmartMatrix.ino │ │ ├── fastled_config.h │ │ ├── LICENSE │ │ ├── led_sysdefs.h │ │ ├── fastspi_types.h │ │ ├── fastled_progmem.h │ │ ├── colorpalettes.h │ │ ├── PORTING.md │ │ ├── power_mgt.h │ │ ├── fastspi_nop.h │ │ ├── color.h │ │ ├── lib8tion │ │ │ └── random8.h │ │ ├── release_notes.md │ │ ├── hsv2rgb.h │ │ └── fastspi.h │ │ ├── Encoder.h │ │ ├── DS1307.h │ │ ├── ChainableLED.h │ │ ├── MMA7660.h │ │ ├── Encoder.cpp │ │ ├── IRSendRev.h │ │ ├── TimerOne.h │ │ ├── MMA7660.cpp │ │ └── TM1637.h ├── firmware_update.sh ├── new_fw_search.sh └── README.md ├── Software ├── Python │ ├── change_log.txt │ ├── DejaVuSansMono.ttf │ ├── friendllyelec.png │ ├── DejaVuSansMono-Bold.ttf │ ├── README.md │ ├── bakebit_buzzer.py │ ├── setup.py │ ├── bakebit_button.py │ ├── bakebit_servo.py │ ├── bakebit_ultrasonic.py │ ├── bakebit_128_64_oled_image.py │ ├── bakebit_128_32_oled_test.py │ ├── bakebit_128_64_oled_test.py │ ├── bakebit_thumb_joystick.py │ ├── bakebit_sound_sensor.py │ ├── bakebit_led_fade.py │ ├── bakebit_prj_Ultrasonic_Sensor_with_LED.py │ ├── bakebit_prj_Button_And_Buzzer.py │ ├── bakebit_led_blink.py │ ├── bakebit_light_sensor.py │ ├── bakebit_prj_Servo_And_RotaryAngleSensor.py │ ├── bakebit_rotary_angle_sensor.py │ ├── bakebit_ledbar.py │ ├── bakebit_128_64_oled_shapes.py │ ├── bakebit_prj_SystemInfo.py │ └── bakebit_prj_SmartLighting.py ├── C │ ├── bakebit_analog_read.c │ ├── bakebit_digital_write.c │ ├── bakebit_analog_write.c │ ├── bakebit_digital_read.c │ ├── bakebit.h │ └── README.md └── README.md ├── Hardware ├── SCHEMATIC1 _ NEO-Hub.pdf └── README.md ├── .gitignore ├── README.zh_CN.md ├── README.md └── .gitattributes /Firmware/version.txt: -------------------------------------------------------------------------------- 1 | 1.0.0 -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/fastspi_dma.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/.gitignore: -------------------------------------------------------------------------------- 1 | html/ 2 | -------------------------------------------------------------------------------- /Software/Python/change_log.txt: -------------------------------------------------------------------------------- 1 | v1.0 2 | 17 Nov 2016 3 | *First time commit -------------------------------------------------------------------------------- /Hardware/SCHEMATIC1 _ NEO-Hub.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/friendlyarm/BakeBit/HEAD/Hardware/SCHEMATIC1 _ NEO-Hub.pdf -------------------------------------------------------------------------------- /Software/Python/DejaVuSansMono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/friendlyarm/BakeBit/HEAD/Software/Python/DejaVuSansMono.ttf -------------------------------------------------------------------------------- /Software/Python/friendllyelec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/friendlyarm/BakeBit/HEAD/Software/Python/friendllyelec.png -------------------------------------------------------------------------------- /Software/Python/DejaVuSansMono-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/friendlyarm/BakeBit/HEAD/Software/Python/DejaVuSansMono-Bold.ttf -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/extras/RainbowDemo.bin.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/friendlyarm/BakeBit/HEAD/Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/extras/RainbowDemo.bin.zip -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/d21/fastled_arm_d21.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_D21_H 2 | #define __INC_FASTLED_ARM_D21_H 3 | 4 | #include "fastled_delay.h" 5 | #include "fastpin_arm_d21.h" 6 | #include "clockless_arm_d21.h" 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/docs/mainpage.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @brief Documentation file for FastLED 3 | @author dgarcia at fastled dot io 4 | @file 5 | */ 6 | /** @defgroup FastLED Sources */ 7 | /** 8 | @mainpage FastLED - let there be light! 9 | */ 10 | EOF 11 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/kl26/fastled_arm_kl26.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_KL26_H 2 | #define __INC_FASTLED_ARM_KL26_H 3 | 4 | // Include the k20 headers 5 | #include "fastled_delay.h" 6 | #include "fastpin_arm_kl26.h" 7 | #include "fastspi_arm_kl26.h" 8 | #include "clockless_arm_kl26.h" 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/stm32/fastled_arm_stm32.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_SAM_H 2 | #define __INC_FASTLED_ARM_SAM_H 3 | 4 | // Include the sam headers 5 | #include "fastled_delay.h" 6 | #include "fastpin_arm_stm32.h" 7 | // #include "fastspi_arm_stm32.h" 8 | #include "clockless_arm_stm32.h" 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/nrf51/fastled_arm_nrf51.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_NRF51_H 2 | #define __INC_FASTLED_ARM_NRF51_H 3 | 4 | // Include the k20 headers 5 | #include "bitswap.h" 6 | #include "fastled_delay.h" 7 | #include "fastpin_arm_nrf51.h" 8 | #include "fastspi_arm_nrf51.h" 9 | #include "clockless_arm_nrf51.h" 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/sam/fastled_arm_sam.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_SAM_H 2 | #define __INC_FASTLED_ARM_SAM_H 3 | 4 | // Include the sam headers 5 | #include "fastled_delay.h" 6 | #include "fastpin_arm_sam.h" 7 | #include "fastspi_arm_sam.h" 8 | #include "clockless_arm_sam.h" 9 | #include "clockless_block_arm_sam.h" 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/avr/fastled_avr.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_AVR_H 2 | #define __INC_FASTLED_AVR_H 3 | 4 | #include "fastled_delay.h" 5 | #include "fastpin_avr.h" 6 | #include "fastspi_avr.h" 7 | #include "clockless_trinket.h" 8 | 9 | // Default to using PROGMEM 10 | #ifndef FASTLED_USE_PROGMEM 11 | #define FASTLED_USE_PROGMEM 1 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /Software/C/bakebit_analog_read.c: -------------------------------------------------------------------------------- 1 | // BakeBit Example for using the analog read. 2 | 3 | #include "bakebit.h" 4 | 5 | int main(void) 6 | { 7 | int adata; 8 | 9 | //Exit on failure to start communications with the BakeBit 10 | if(init()==-1) 11 | exit(1); 12 | 13 | while(1) 14 | { 15 | adata=analogRead(0); 16 | printf("analog read %d\n",adata); 17 | if(adata==-1) 18 | printf("IO Error"); 19 | } 20 | return 1; 21 | } 22 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/k20/fastled_arm_k20.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_ARM_K20_H 2 | #define __INC_FASTLED_ARM_K20_H 3 | 4 | // Include the k20 headers 5 | #include "bitswap.h" 6 | #include "fastled_delay.h" 7 | #include "fastpin_arm_k20.h" 8 | #include "fastspi_arm_k20.h" 9 | #include "octows2811_controller.h" 10 | #include "smartmatrix_t3.h" 11 | #include "clockless_arm_k20.h" 12 | #include "clockless_block_arm_k20.h" 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /Software/C/bakebit_digital_write.c: -------------------------------------------------------------------------------- 1 | //BakeBit Example for using the digital write command 2 | #include "bakebit.h" 3 | //gcc bakebit_digital_write.c bakebit.c -Wall 4 | 5 | int main(void) 6 | { 7 | //Exit on failure to start communications with the BakeBit 8 | if(init()==-1) 9 | exit(1); 10 | 11 | //Set pin mode to output 12 | pinMode(4,1); 13 | while(1) 14 | { 15 | digitalWrite(4,1); 16 | pi_sleep(500); 17 | digitalWrite(4,0); 18 | pi_sleep(500); 19 | } 20 | return 1; 21 | } 22 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/library.properties: -------------------------------------------------------------------------------- 1 | name=FastLED 2 | version=3.1.0 3 | author=Daniel Garcia 4 | maintainer=Daniel Garcia 5 | sentence=Multi-platform library for controlling dozens of different types of LEDs along with optimized math, effect, and noise functions. 6 | paragraph=Multi-platform library for controlling dozens of different types of LEDs along with optimized math, effect, and noise functions. 7 | category=Display 8 | url=https://github.com/FastLED/FastLED 9 | architectures=* 10 | -------------------------------------------------------------------------------- /Software/C/bakebit_analog_write.c: -------------------------------------------------------------------------------- 1 | // BakeBit Example for using the analog write 2 | 3 | #include "bakebit.h" 4 | //gcc bakebit_analog_write.c bakebit.c -Wall 5 | int main(void) 6 | { 7 | int i; 8 | 9 | //Exit on failure to start communications with the BakeBit 10 | if(init()==-1) 11 | exit(1); 12 | 13 | while(1) 14 | { 15 | for(i=0;i<256;i++) 16 | { 17 | printf("%d\n", i); 18 | //Write the PWM value 19 | analogWrite(3,i); 20 | //Sleep for 10ms 21 | pi_sleep(10); 22 | } 23 | } 24 | return 1; 25 | } 26 | -------------------------------------------------------------------------------- /Software/C/bakebit_digital_read.c: -------------------------------------------------------------------------------- 1 | // BakeBit Example for using the digital read command 2 | 3 | #include "bakebit.h" 4 | //gcc bakebit_digital_read.c bakebit.c -Wall 5 | int main(void) 6 | { 7 | int dval; 8 | 9 | //Exit on failure to start communications with the BakeBit 10 | if(init()==-1) 11 | exit(1); 12 | 13 | //Set pin mode to input 14 | pinMode(4,0); 15 | while(1) 16 | { 17 | dval=digitalRead(2); 18 | printf("Digital read %d\n", dval); 19 | //Sleep for 50ms 20 | pi_sleep(50); 21 | } 22 | return 1; 23 | } 24 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/d21/led_sysdefs_arm_d21.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_D21_H 2 | #define __INC_LED_SYSDEFS_ARM_D21_H 3 | 4 | 5 | #define FASTLED_ARM 6 | #define FASTLED_ARM_M0_PLUS 7 | 8 | #ifndef INTERRUPT_THRESHOLD 9 | #define INTERRUPT_THRESHOLD 1 10 | #endif 11 | 12 | // Default to allowing interrupts 13 | #ifndef FASTLED_ALLOW_INTERRUPTS 14 | #define FASTLED_ALLOW_INTERRUPTS 0 15 | #endif 16 | 17 | #if FASTLED_ALLOW_INTERRUPTS == 1 18 | #define FASTLED_ACCURATE_CLOCK 19 | #endif 20 | 21 | // reuseing/abusing cli/sei defs for due 22 | #define cli() __disable_irq(); 23 | #define sei() __enable_irq(); 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/extras/AppleII.s65: -------------------------------------------------------------------------------- 1 | KBD = $C000 ;Read keydown 2 | KBDSTRB = $C010 ;Reset keybd 3 | 4 | SPKR = $C030 ;Toggle speaker 5 | 6 | ; TTL digital output pins on 7 | ; 16-pin DIP game connector 8 | SETAN0 = $C058 9 | CLRAN0 = $C059 10 | SETAN1 = $C05A 11 | CLRAN1 = $C05B 12 | SETAN2 = $C05C 13 | CLRAN2 = $C05D 14 | SETAN3 = $C05E 15 | CLRAN3 = $C05F 16 | 17 | PIN12ON = CLRAN3 18 | PIN12OFF= SETAN3 19 | PIN13ON = CLRAN2 20 | PIN13OFF= SETAN2 21 | PIN14ON = CLRAN1 22 | PIN14OFF= SETAN1 23 | PIN15ON = CLRAN0 24 | PIN15OFF= SETAN0 25 | 26 | ;Special for pin 5, except on //gs 27 | C040STROBE = $C040 28 | PIN5STROBE = C040STROBE 29 | 30 | SolidApple = $C062 ; read SW1 or SA 31 | OpenApple = $C061 ; read SW0 or OA 32 | 33 | VBL = $C019 ; vertical blanking 34 | 35 | WAIT = $FCA8 ; wait a little while 36 | 37 | CROUT = $FD8E ; print a CR 38 | PRBYTE = $FDDA ; print a hex byte 39 | 40 | 41 | -------------------------------------------------------------------------------- /Hardware/README.md: -------------------------------------------------------------------------------- 1 | NEO-Hub by FriendlyARM 2 | NEO-Hub is an electronics board designed by FriendlyARM that you can connect to hundreds of different sensors, so you can program them to monitor, control, and automate devices in your life. 3 | 4 | ## License 5 | 6 | GNU General Public License v3.0 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation, either version 3 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. If not, see . -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_PLATFORMS_H 2 | #define __INC_PLATFORMS_H 3 | 4 | #include "fastled_config.h" 5 | 6 | #if defined(NRF51) 7 | #include "platforms/arm/nrf51/fastled_arm_nrf51.h" 8 | #elif defined(__MK20DX128__) || defined(__MK20DX256__) 9 | // Include k20/T3 headers 10 | #include "platforms/arm/k20/fastled_arm_k20.h" 11 | #elif defined(__MKL26Z64__) 12 | // Include kl26/T-LC headers 13 | #include "platforms/arm/kl26/fastled_arm_kl26.h" 14 | #elif defined(__SAM3X8E__) 15 | // Include sam/due headers 16 | #include "platforms/arm/sam/fastled_arm_sam.h" 17 | #elif defined(STM32F10X_MD) 18 | #include "platforms/arm/stm32/fastled_arm_stm32.h" 19 | #elif defined(__SAMD21G18A__) 20 | #include "platforms/arm/d21/fastled_arm_d21.h" 21 | #elif defined(__XTENSA__) 22 | #error "XTENSA-architecture microcontrollers are not supported" 23 | #else 24 | // AVR platforms 25 | #include "platforms/avr/fastled_avr.h" 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Software/C/bakebit.h: -------------------------------------------------------------------------------- 1 | #ifndef BAKEBIT_H 2 | #define BAKEBIT_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | extern int fd; 15 | extern char *fileName; 16 | extern int address; 17 | extern unsigned char w_buf[5],r_buf[32]; 18 | extern unsigned long reg_addr; 19 | 20 | #define dRead_cmd 1 21 | #define dWrite_cmd 2 22 | #define aRead_cmd 3 23 | #define aWrite_cmd 4 24 | #define pMode_cmd 5 25 | //Initialize 26 | int init(void); 27 | //Write a register 28 | int write_block(char cmd,char v1,char v2,char v3); 29 | //Read 1 byte of data 30 | char read_byte(void); 31 | 32 | void pi_sleep(int); 33 | int analogRead(int pin); 34 | int digitalWrite(int pin,int value); 35 | int pinMode(int pin,int mode); 36 | int digitalRead(int pin); 37 | int analogWrite(int pin,int value); 38 | #endif /*BAKEBIT_H */ 39 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/preview_changes.txt: -------------------------------------------------------------------------------- 1 | FastLED 3.1 preview changes: 2 | * UART in SPI mode support on AVR 3 | * Support for using both hardware SPI pinsets on the Teensy 3.x - 11/13 and 7/14. 4 | * Added UCS1904 support 5 | * Better AVR cycle counting 6 | * Split WS2812/WS2811 timings 7 | * Added DOTSTAR definition for adafruit dotstar pixels (aka APA102) 8 | * 8-way parallel output on teensy 3, 3.1 (portc,portd), due/digix (porta, portb, portd) 9 | * 12-way parallel output on teensy 3, 3.1 (portc) 10 | * 16-way parallel output on teensy 3, 3.1 (portc & portd paired) 11 | * refresh rate limiting 12 | * interrupt friendly code on teensy 3/3.1 13 | * -interrupt friendly code on AVR- <-- disabled for now 14 | * interrupt friendly code on the due 15 | * code re-org for future wider platform support 16 | * Spark Core support 17 | * arduino zero support (no hardware spi yet) 18 | * greatly improved clockless output for avr 19 | * greatly improved clockless output for arm m0 boards 20 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/Multiple/OctoWS2811Demo/OctoWS2811Demo.ino: -------------------------------------------------------------------------------- 1 | #define USE_OCTOWS2811 2 | #include 3 | #include 4 | 5 | #define NUM_LEDS_PER_STRIP 64 6 | #define NUM_STRIPS 8 7 | 8 | CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP]; 9 | 10 | // Pin layouts on the teensy 3: 11 | // OctoWS2811: 2,14,7,8,6,20,21,5 12 | 13 | void setup() { 14 | LEDS.addLeds(leds, NUM_LEDS_PER_STRIP); 15 | LEDS.setBrightness(32); 16 | } 17 | 18 | void loop() { 19 | static uint8_t hue = 0; 20 | for(int i = 0; i < NUM_STRIPS; i++) { 21 | for(int j = 0; j < NUM_LEDS_PER_STRIP; j++) { 22 | leds[(i*NUM_LEDS_PER_STRIP) + j] = CHSV((32*i) + hue+j,192,255); 23 | } 24 | } 25 | 26 | // Set the first n leds on each strip to show which strip it is 27 | for(int i = 0; i < NUM_STRIPS; i++) { 28 | for(int j = 0; j <= i; j++) { 29 | leds[(i*NUM_LEDS_PER_STRIP) + j] = CRGB::Red; 30 | } 31 | } 32 | 33 | hue++; 34 | 35 | LEDS.show(); 36 | LEDS.delay(10); 37 | } 38 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/nrf51/led_sysdefs_arm_nrf51.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_SYSDEFS_ARM_NRF51 2 | #define __LED_SYSDEFS_ARM_NRF51 3 | 4 | #ifndef NRF51 5 | #define NRF51 6 | #endif 7 | 8 | #define LED_TIMER NRF_TIMER1 9 | #define FASTLED_NO_PINMAP 10 | #define FASTLED_HAS_CLOCKLESS 11 | 12 | #define FASTLED_ARM 13 | #define FASTLED_ARM_M0 14 | 15 | #ifndef F_CPU 16 | #define F_CPU 16000000 17 | #endif 18 | 19 | #include 20 | #include "nrf51.h" 21 | #include "core_cm0.h" 22 | 23 | typedef volatile uint32_t RoReg; 24 | typedef volatile uint32_t RwReg; 25 | typedef uint32_t prog_uint32_t; 26 | typedef uint8_t boolean; 27 | 28 | #define PROGMEM 29 | #define NO_PROGMEM 30 | #define NEED_CXX_BITS 31 | 32 | // Default to NOT using PROGMEM here 33 | #ifndef FASTLED_USE_PROGMEM 34 | #define FASTLED_USE_PROGMEM 0 35 | #endif 36 | 37 | #ifndef FASTLED_ALLOW_INTERRUPTS 38 | #define FASTLED_ALLOW_INTERRUPTS 1 39 | #endif 40 | 41 | #define cli() __disable_irq(); 42 | #define sei() __enable_irq(); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /Firmware/firmware_update.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | echo "Updating the BakeBit firmware" 3 | echo "=============================" 4 | echo " http://wiki.friendlyarm.com/BakeBit " 5 | echo " Run this program: " 6 | echo " sudo ./firmware_update.sh" 7 | echo " " 8 | echo "=============================" 9 | 10 | read -n1 -p "Do you want to update the firmware? [y,n]" input 11 | if [[ $input == "Y" || $input == "y" ]]; then 12 | printf "\nMake sure that NEO-Hub is connected to NanoPi-NEO" 13 | else 14 | printf "\nExiting..." 15 | exit 0 16 | fi 17 | if [ $(find $pwd -name "bakebit_firmware.hex") ]; then 18 | printf "\nFirmware found" 19 | else 20 | printf "\nFirmware not found\nCheck if firmware is there or run again\nPress any key to exit" 21 | read 22 | exit 0 23 | fi 24 | 25 | printf "\nPress any key to start firmware update\n. . ."; 26 | read -n1 27 | avrdude -c nanopineo -p m328p -U lfuse:w:0xFF:m 28 | avrdude -c nanopineo -p m328p -U hfuse:w:0xDA:m 29 | avrdude -c nanopineo -p m328p -U efuse:w:0x05:m 30 | avrdude -c nanopineo -p m328p -U flash:w:bakebit_firmware.hex -F 31 | 32 | 33 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/fastled_config.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTLED_CONFIG_H 2 | #define __INC_FASTLED_CONFIG_H 3 | 4 | ///@file fastled_config.h 5 | /// contains definitions that can be used to configure FastLED at compile time 6 | 7 | // Use this option only for debugging pin access and forcing software pin access. Note that 8 | // software pin access only works in Arduino based environments. Forces use of digitalWrite 9 | // methods for pin access vs. direct hardware port access 10 | // #define FASTLED_FORCE_SOFTWARE_PINS 11 | 12 | // Use this option only for debugging bitbang'd spi access or to work around bugs in hardware 13 | // spi access. Forces use of bit-banged spi, even on pins that has hardware SPI available. 14 | // #define FASTLED_FORCE_SOFTWARE_SPI 15 | 16 | // Use this to force FastLED to allow interrupts in the clockless chipsets (or to force it to 17 | // disallow), overriding the default on platforms that support this. Set the value to 1 to 18 | // allow interrupts or 0 to disallow them. 19 | // #define FASTLED_ALLOW_INTERRUPTS 1 20 | // #define FASTLED_ALLOW_INTERRUPTS 0 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /Firmware/new_fw_search.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | printf "Welcome to BakeBit Firmware Update Check.\n=========================================\nPlease ensure internet connectivity before running this script.\n" 3 | echo "Must be running as Root user" 4 | echo "Press any key to begin..." 5 | read 6 | 7 | echo "Check for internet connectivity..." 8 | echo "==================================" 9 | wget -q --tries=2 --timeout=20 --output-document=/dev/null http://baidu.com 10 | if [[ $? -eq 0 ]];then 11 | echo "Connected" 12 | else 13 | echo "Unable to Connect, try again !!!" 14 | exit 0 15 | fi 16 | 17 | wget http://wiki.friendlyarm.com/bakebit/Firmware/version.txt -O temp_f &>/dev/null 18 | diff -q version.txt temp_f 19 | if [[ $? == "0" ]] 20 | then 21 | echo "You have the latest firmware" 22 | else 23 | printf "\nNew firmware available. \n\nDownload the new version from BakeBit Github Repo.\n" 24 | printf "\nTo download the latest firmware, simply open a terminal session, change directories to the Github on your NanoPi, and type 'git remote update'. This will pull the latest files from Github. Then run this script again." 25 | fi 26 | rm temp_f 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ========================= 2 | # Repository Ingores 3 | # ========================= 4 | Software/Python/__pycache__ 5 | Software/Python/.idea 6 | WiringNP 7 | 8 | # Vim backup 9 | README.md~ 10 | # Vim swap 11 | *.swp 12 | 13 | # ========================= 14 | # Windows Cached Files 15 | # ========================= 16 | # Windows image file caches 17 | Thumbs.db 18 | ehthumbs.db 19 | 20 | # Folder config file 21 | Desktop.ini 22 | 23 | # Recycle Bin used on file shares 24 | $RECYCLE.BIN/ 25 | 26 | # Windows Installer files 27 | *.cab 28 | *.msi 29 | *.msm 30 | *.msp 31 | 32 | # Windows shortcuts 33 | *.lnk 34 | 35 | # Visual Studio files 36 | Debug 37 | bin 38 | obj 39 | Release 40 | *.pyc 41 | *.pfx 42 | *.suo 43 | *.user 44 | 45 | # ========================= 46 | # Mac OS Cached Files 47 | # ========================= 48 | .DS_Store 49 | .AppleDouble 50 | .LSOverride 51 | 52 | # Thumbnails 53 | ._* 54 | 55 | # Files that might appear on external disk 56 | .Spotlight-V100 57 | .Trashes 58 | 59 | # Directories potentially created on remote AFP share 60 | .AppleDB 61 | .AppleDesktop 62 | Network Trash Folder 63 | Temporary Items 64 | .apdisk 65 | 66 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 FastLED 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/Encoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | 2012 Copyright (c) Seeed Technology Inc. 3 | 4 | Author: LG 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc.,51 Franklin St,Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | */ 21 | #ifndef Encoder_h 22 | #define Encoder_h 23 | 24 | //#include 25 | 26 | class Encoder 27 | { 28 | public: 29 | Encoder(); 30 | void Timer_init(void); 31 | void Timer_disable(void); 32 | char direct; 33 | //char direct_b; 34 | char rotate_flag; 35 | }; 36 | 37 | extern Encoder encoder; 38 | #endif; 39 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/sam/led_sysdefs_arm_sam.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_SAM_H 2 | #define __INC_LED_SYSDEFS_ARM_SAM_H 3 | 4 | 5 | #define FASTLED_ARM 6 | 7 | // Setup DUE timer defines/channels/etc... 8 | #ifndef DUE_TIMER_CHANNEL 9 | #define DUE_TIMER_GROUP 0 10 | #endif 11 | 12 | #ifndef DUE_TIMER_CHANNEL 13 | #define DUE_TIMER_CHANNEL 0 14 | #endif 15 | 16 | #define DUE_TIMER ((DUE_TIMER_GROUP==0) ? TC0 : ((DUE_TIMER_GROUP==1) ? TC1 : TC2)) 17 | #define DUE_TIMER_ID (ID_TC0 + (DUE_TIMER_GROUP*3) + DUE_TIMER_CHANNEL) 18 | #define DUE_TIMER_VAL (DUE_TIMER->TC_CHANNEL[DUE_TIMER_CHANNEL].TC_CV << 1) 19 | #define DUE_TIMER_RUNNING ((DUE_TIMER->TC_CHANNEL[DUE_TIMER_CHANNEL].TC_SR & TC_SR_CLKSTA) != 0) 20 | 21 | #ifndef INTERRUPT_THRESHOLD 22 | #define INTERRUPT_THRESHOLD 1 23 | #endif 24 | 25 | // Default to allowing interrupts 26 | #ifndef FASTLED_ALLOW_INTERRUPTS 27 | #define FASTLED_ALLOW_INTERRUPTS 1 28 | #endif 29 | 30 | #if FASTLED_ALLOW_INTERRUPTS == 1 31 | #define FASTLED_ACCURATE_CLOCK 32 | #endif 33 | 34 | // reusing/abusing cli/sei defs for due 35 | #define cli() __disable_irq(); __disable_fault_irq(); 36 | #define sei() __enable_irq(); __enable_fault_irq(); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /README.zh_CN.md: -------------------------------------------------------------------------------- 1 | ## **BakeBit** 2 | 3 | [English](https://github.com/friendlyarm/BakeBit) 4 | [汉语](https://github.com/friendlyarm/BakeBit/blob/master/README.zh_CN.md) 5 | 6 | 7 | BakeBit 是一个基于 GrovePi 的开源平台, 它连接 NanoPi 上的 BakeBit 传感器. 8 | 9 | 当前支持的主板: NanoPi NEO, NanoPi NEO2, NanoPi NEO Air. 10 | 11 | ## 说明 12 | 13 | 它能够在FriendlyCore、Armbian或Ubuntu Core 系统的 Python3.x 环境工作. 14 | 15 | 基于尽量充分利用 Debian/Ubuntu 发行版的 APT 包管理器进而达到稳定及更新的目的, 16 | 本代码分支在安装过程中放弃使用 Python3 包管理器 (PIP) 并移除老旧依赖库. 17 | 由于APT源中依赖库的缺失, 兼容模式的安装脚本未移除PIP. 18 | 将依赖库 WiringNP 直接连接于 https://github.com/friendlyarm/WiringNP 并在安装时自动下载更新. 19 | 20 | 原始实现基于Python2,感谢[CuitGGyy](https://github.com/CuitGGyy/BakeBit)将其移植到Python3.x环境. 21 | 22 | ## 安装 23 | 24 | #### FriendlyCore Xenial / Armbian Stretch / Ubuntu Core Xenial 25 | 26 | ``` 27 | # git clone --depth=1 https://github.com/friendlyarm/BakeBit.git 28 | # cd BakeBit 29 | # sudo -H ./install.sh 30 | ``` 31 | 32 | #### FriendlyCore Focal / Armbian Buster / Ubuntu Core Bionic 33 | 34 | ``` 35 | # git clone --depth=1 https://github.com/friendlyarm/BakeBit.git 36 | # cd BakeBit 37 | # sudo -H ./install-compat.sh 38 | ``` 39 | 40 | 演示代码将在系统重新启动后自动运行. 41 | 42 | ## 协议 43 | 44 | The MIT License (MIT) 45 | 46 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 47 | Copyright (C) 2016 FriendlyARM 48 | 49 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/k20/led_sysdefs_arm_k20.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_K20_H 2 | #define __INC_LED_SYSDEFS_ARM_K20_H 3 | 4 | #define FASTLED_TEENSY3 5 | #define FASTLED_ARM 6 | 7 | #ifndef INTERRUPT_THRESHOLD 8 | #define INTERRUPT_THRESHOLD 1 9 | #endif 10 | 11 | // Default to allowing interrupts 12 | #ifndef FASTLED_ALLOW_INTERRUPTS 13 | #define FASTLED_ALLOW_INTERRUPTS 1 14 | #endif 15 | 16 | #if FASTLED_ALLOW_INTERRUPTS == 1 17 | #define FASTLED_ACCURATE_CLOCK 18 | #endif 19 | 20 | #if (F_CPU == 96000000) 21 | #define CLK_DBL 1 22 | #endif 23 | 24 | // Get some system include files 25 | #include 26 | #include // for cli/se definitions 27 | 28 | // Define the register types 29 | #if defined(ARDUINO) // && ARDUINO < 150 30 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 31 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 32 | #endif 33 | 34 | extern volatile uint32_t systick_millis_count; 35 | # define MS_COUNTER systick_millis_count 36 | 37 | 38 | // Default to using PROGMEM, since TEENSY3 provides it 39 | // even though all it does is ignore it. Just being 40 | // conservative here in case TEENSY3 changes. 41 | #ifndef FASTLED_USE_PROGMEM 42 | #define FASTLED_USE_PROGMEM 1 43 | #endif 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/led_sysdefs.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_H 2 | #define __INC_LED_SYSDEFS_H 3 | 4 | #include "fastled_config.h" 5 | 6 | #if defined(NRF51) || defined(__RFduino__) 7 | #include "platforms/arm/nrf51/led_sysdefs_arm_nrf51.h" 8 | #elif defined(__MK20DX128__) || defined(__MK20DX256__) 9 | // Include k20/T3 headers 10 | #include "platforms/arm/k20/led_sysdefs_arm_k20.h" 11 | #elif defined(__MKL26Z64__) 12 | // Include kl26/T-LC headers 13 | #include "platforms/arm/kl26/led_sysdefs_arm_kl26.h" 14 | #elif defined(__SAM3X8E__) 15 | // Include sam/due headers 16 | #include "platforms/arm/sam/led_sysdefs_arm_sam.h" 17 | #elif defined(STM32F10X_MD) 18 | #include "platforms/arm/stm32/led_sysdefs_arm_stm32.h" 19 | #elif defined(__SAMD21G18A__) 20 | #include "platforms/arm/d21/led_sysdefs_arm_d21.h" 21 | #elif defined(__XTENSA__) 22 | #error "XTENSA-architecture microcontrollers are not supported." 23 | #else 24 | // AVR platforms 25 | #include "platforms/avr/led_sysdefs_avr.h" 26 | #endif 27 | 28 | #ifndef FASTLED_NAMESPACE_BEGIN 29 | #define FASTLED_NAMESPACE_BEGIN 30 | #define FASTLED_NAMESPACE_END 31 | #define FASTLED_USING_NAMESPACE 32 | #endif 33 | 34 | // Arduino.h needed for convenience functions digitalPinToPort/BitMask/portOutputRegister and the pinMode methods. 35 | #ifdef ARDUINO 36 | #include 37 | #endif 38 | 39 | #define CLKS_PER_US (F_CPU/1000000) 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/kl26/led_sysdefs_arm_kl26.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_KL26_H 2 | #define __INC_LED_SYSDEFS_ARM_KL26_H 3 | 4 | #define FASTLED_TEENSYLC 5 | #define FASTLED_ARM 6 | #define FASTLED_ARM_M0_PLUS 7 | 8 | #ifndef INTERRUPT_THRESHOLD 9 | #define INTERRUPT_THRESHOLD 1 10 | #endif 11 | 12 | // Default to allowing interrupts 13 | #ifndef FASTLED_ALLOW_INTERRUPTS 14 | #define FASTLED_ALLOW_INTERRUPTS 1 15 | #endif 16 | 17 | #if FASTLED_ALLOW_INTERRUPTS == 1 18 | #define FASTLED_ACCURATE_CLOCK 19 | #endif 20 | 21 | #if (F_CPU == 96000000) 22 | #define CLK_DBL 1 23 | #endif 24 | 25 | // Get some system include files 26 | #include 27 | #include // for cli/se definitions 28 | 29 | // Define the register types 30 | #if defined(ARDUINO) // && ARDUINO < 150 31 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 32 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 33 | #endif 34 | 35 | extern volatile uint32_t systick_millis_count; 36 | # define MS_COUNTER systick_millis_count 37 | 38 | // Default to using PROGMEM since TEENSYLC provides it 39 | // even though all it does is ignore it. Just being 40 | // conservative here in case TEENSYLC changes. 41 | #ifndef FASTLED_USE_PROGMEM 42 | #define FASTLED_USE_PROGMEM 1 43 | #endif 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Software/README.md: -------------------------------------------------------------------------------- 1 | BakeBit 2 | ======= 3 | 4 | BakeBit for the NanoPi NEO: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 5 | 6 | 7 | ## License 8 | 9 | The MIT License (MIT) 10 | 11 | BakeBit for the NanoPi NEO: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 12 | Copyright (C) 2016 FriendlyARM 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. -------------------------------------------------------------------------------- /Firmware/README.md: -------------------------------------------------------------------------------- 1 | BakeBit 2 | ======= 3 | 4 | BakeBit is an open source platform for connecting BakeBit Sensors to the NanoPi. [See more about the BakeBit here.](https://github.com/friendlyarm/bakebit) 5 | 6 | 7 | ## License 8 | 9 | The MIT License (MIT) 10 | 11 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 12 | Copyright (C) 2016 FriendlyARM 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/stm32/led_sysdefs_arm_stm32.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_ARM_SAM_H 2 | #define __INC_LED_SYSDEFS_ARM_SAM_H 3 | 4 | #include "application.h" 5 | 6 | #define FASTLED_NAMESPACE_BEGIN namespace NSFastLED { 7 | #define FASTLED_NAMESPACE_END } 8 | #define FASTLED_USING_NAMESPACE using namespace NSFastLED; 9 | 10 | #define FASTLED_ARM 11 | 12 | #ifndef INTERRUPT_THRESHOLD 13 | #define INTERRUPT_THRESHOLD 1 14 | #endif 15 | 16 | // Default to allowing interrupts 17 | #ifndef FASTLED_ALLOW_INTERRUPTS 18 | #define FASTLED_ALLOW_INTERRUPTS 0 19 | #endif 20 | 21 | #if FASTLED_ALLOW_INTERRUPTS == 1 22 | #define FASTLED_ACCURATE_CLOCK 23 | #endif 24 | 25 | // reusing/abusing cli/sei defs for due 26 | #define cli() __disable_irq(); __disable_fault_irq(); 27 | #define sei() __enable_irq(); __enable_fault_irq(); 28 | 29 | // pgmspace definitions 30 | #define PROGMEM 31 | #define pgm_read_dword(addr) (*(const unsigned long *)(addr)) 32 | #define pgm_read_dword_near(addr) pgm_read_dword(addr) 33 | 34 | // Default to NOT using PROGMEM here 35 | #ifndef FASTLED_USE_PROGMEM 36 | #define FASTLED_USE_PROGMEM 0 37 | #endif 38 | 39 | // data type defs 40 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 41 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 42 | 43 | #define FASTLED_NO_PINMAP 44 | 45 | #define F_CPU 72000000 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/Multiple/MultipleStripsInOneArray/MultipleStripsInOneArray.ino: -------------------------------------------------------------------------------- 1 | // MultipleStripsInOneArray - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on 2 | // using multiple controllers. In this example, we're going to set up four NEOPIXEL strips on three 3 | // different pins, each strip will be referring to a different part of the single led array 4 | 5 | #include "FastLED.h" 6 | 7 | #define NUM_STRIPS 3 8 | #define NUM_LEDS_PER_STRIP 60 9 | #define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS 10 | 11 | CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP]; 12 | 13 | // For mirroring strips, all the "special" stuff happens just in setup. We 14 | // just addLeds multiple times, once for each strip 15 | void setup() { 16 | // tell FastLED there's 60 NEOPIXEL leds on pin 10, starting at index 0 in the led array 17 | FastLED.addLeds(leds, 0, NUM_LEDS_PER_STRIP); 18 | 19 | // tell FastLED there's 60 NEOPIXEL leds on pin 11, starting at index 60 in the led array 20 | FastLED.addLeds(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP); 21 | 22 | // tell FastLED there's 60 NEOPIXEL leds on pin 12, starting at index 120 in the led array 23 | FastLED.addLeds(leds, 2 * NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP); 24 | 25 | } 26 | 27 | void loop() { 28 | for(int i = 0; i < NUM_LEDS; i++) { 29 | leds[i] = CRGB::Red; 30 | FastLED.show(); 31 | leds[i] = CRGB::Black; 32 | delay(100); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Software/Python/README.md: -------------------------------------------------------------------------------- 1 | BakeBit 2 | ======= 3 | 4 | BakeBit for the NanoPi NEO: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 5 | 6 | See more at the [BakeBit WiKi](http://wiki.friendlyarm.com/BakeBit) 7 | 8 | 9 | ## License 10 | 11 | The MIT License (MIT) 12 | 13 | BakeBit for the NanoPi NEO: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 14 | Copyright (C) 2016 FriendlyARM 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining a copy 17 | of this software and associated documentation files (the "Software"), to deal 18 | in the Software without restriction, including without limitation the rights 19 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20 | copies of the Software, and to permit persons to whom the Software is 21 | furnished to do so, subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be included in 24 | all copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 32 | THE SOFTWARE. 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/Multiple/ArrayOfLedArrays/ArrayOfLedArrays.ino: -------------------------------------------------------------------------------- 1 | // ArrayOfLedArrays - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on 2 | // using multiple controllers. In this example, we're going to set up four NEOPIXEL strips on three 3 | // different pins, each strip getting its own CRGB array to be played with, only this time they're going 4 | // to be all parts of an array of arrays. 5 | 6 | #include "FastLED.h" 7 | 8 | #define NUM_STRIPS 3 9 | #define NUM_LEDS_PER_STRIP 60 10 | CRGB leds[NUM_STRIPS][NUM_LEDS_PER_STRIP]; 11 | 12 | // For mirroring strips, all the "special" stuff happens just in setup. We 13 | // just addLeds multiple times, once for each strip 14 | void setup() { 15 | // tell FastLED there's 60 NEOPIXEL leds on pin 10 16 | FastLED.addLeds(leds[0], NUM_LEDS_PER_STRIP); 17 | 18 | // tell FastLED there's 60 NEOPIXEL leds on pin 11 19 | FastLED.addLeds(leds[1], NUM_LEDS_PER_STRIP); 20 | 21 | // tell FastLED there's 60 NEOPIXEL leds on pin 12 22 | FastLED.addLeds(leds[2], NUM_LEDS_PER_STRIP); 23 | 24 | } 25 | 26 | void loop() { 27 | // This outer loop will go over each strip, one at a time 28 | for(int x = 0; x < NUM_STRIPS; x++) { 29 | // This inner loop will go over each led in the current strip, one at a time 30 | for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) { 31 | leds[x][i] = CRGB::Red; 32 | FastLED.show(); 33 | leds[x][i] = CRGB::Black; 34 | delay(100); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Software/C/README.md: -------------------------------------------------------------------------------- 1 | BakeBit C library 2 | v0.1 3 | 4 | This library provides the basic functions for using the BakeBit in C. 5 | 6 | To compile use: 7 | gcc programe_name.c bakebit.c -Wall 8 | e.g.: gcc bakebit_analog_read.c bakebit.c -Wall 9 | 10 | and then run the executable: 11 | ./a.out 12 | 13 | ### 14 | License 15 | 16 | The MIT License (MIT) 17 | 18 | BakeBit for the NanoPi NEO: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 19 | Copyright (C) 2016 FriendlyARM 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in 29 | all copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 37 | THE SOFTWARE. -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/avr/led_sysdefs_avr.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LED_SYSDEFS_AVR_H 2 | #define __INC_LED_SYSDEFS_AVR_H 3 | 4 | #define FASTLED_AVR 5 | 6 | #ifndef INTERRUPT_THRESHOLD 7 | #define INTERRUPT_THRESHOLD 2 8 | #endif 9 | 10 | #include 11 | #include // for cli/se definitions 12 | 13 | // Define the register types 14 | #if defined(ARDUINO) // && ARDUINO < 150 15 | typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ 16 | typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ 17 | #endif 18 | 19 | 20 | // Default to disallowing interrupts (may want to gate this on teensy2 vs. other arm platforms, since the 21 | // teensy2 has a good, fast millis interrupt implementation) 22 | #ifndef FASTLED_ALLOW_INTERRUPTS 23 | #define FASTLED_ALLOW_INTERRUPTS 0 24 | #endif 25 | 26 | #if FASTLED_ALLOW_INTERRUPTS == 1 27 | #define FASTLED_ACCURATE_CLOCK 28 | #endif 29 | 30 | 31 | // Default to using PROGMEM here 32 | #ifndef FASTLED_USE_PROGMEM 33 | #define FASTLED_USE_PROGMEM 1 34 | #endif 35 | 36 | #if defined(ARDUINO_AVR_DIGISPARK) || defined(ARDUINO_AVR_DIGISPARKPRO) 37 | #ifndef NO_CORRECTION 38 | #define NO_CORRECTION 1 39 | #endif 40 | #endif 41 | 42 | extern "C" { 43 | # if defined(CORE_TEENSY) || defined(TEENSYDUINO) 44 | extern volatile unsigned long timer0_millis_count; 45 | # define MS_COUNTER timer0_millis_count 46 | # else 47 | extern volatile unsigned long timer0_millis; 48 | # define MS_COUNTER timer0_millis 49 | # endif 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/fastspi_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTSPI_TYPES_H 2 | #define __INC_FASTSPI_TYPES_H 3 | 4 | FASTLED_NAMESPACE_BEGIN 5 | 6 | // Some helper macros for getting at mis-ordered byte values 7 | #define SPI_B0 (RGB_BYTE0(RGB_ORDER) + (MASK_SKIP_BITS & SKIP)) 8 | #define SPI_B1 (RGB_BYTE1(RGB_ORDER) + (MASK_SKIP_BITS & SKIP)) 9 | #define SPI_B2 (RGB_BYTE2(RGB_ORDER) + (MASK_SKIP_BITS & SKIP)) 10 | #define SPI_ADVANCE (3 + (MASK_SKIP_BITS & SKIP)) 11 | 12 | /// Some of the SPI controllers will need to perform a transform on each byte before doing 13 | /// anyting with it. Creating a class of this form and passing it in as a template parameter to 14 | /// writeBytes/writeBytes3 below will ensure that the body of this method will get called on every 15 | /// byte worked on. Recommendation, make the adjust method aggressively inlined. 16 | /// 17 | /// TODO: Convinience macro for building these 18 | class DATA_NOP { 19 | public: 20 | static __attribute__((always_inline)) inline uint8_t adjust(register uint8_t data) { return data; } 21 | static __attribute__((always_inline)) inline uint8_t adjust(register uint8_t data, register uint8_t scale) { return scale8(data, scale); } 22 | static __attribute__((always_inline)) inline void postBlock(int len) {} 23 | }; 24 | 25 | #define FLAG_START_BIT 0x80 26 | #define MASK_SKIP_BITS 0x3F 27 | 28 | // Clock speed dividers 29 | #define SPEED_DIV_2 2 30 | #define SPEED_DIV_4 4 31 | #define SPEED_DIV_8 8 32 | #define SPEED_DIV_16 16 33 | #define SPEED_DIV_32 32 34 | #define SPEED_DIV_64 64 35 | #define SPEED_DIV_128 128 36 | 37 | #define MAX_DATA_RATE 0 38 | 39 | FASTLED_NAMESPACE_END 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/Blink/Blink.ino: -------------------------------------------------------------------------------- 1 | #include "FastLED.h" 2 | 3 | // How many leds in your strip? 4 | #define NUM_LEDS 5 5 | #define DATA_PIN 3 6 | // Define the array of leds 7 | CRGB leds[NUM_LEDS]; 8 | 9 | #define ROTARY_ANGLE_SENSOR A0 10 | #define ADC_REF 5 11 | #define FULL_ANGLE 360 12 | #define GROVE_VCC 5 13 | 14 | 15 | void setup() { 16 | pinMode(ROTARY_ANGLE_SENSOR, INPUT); 17 | Serial.begin(115200); 18 | FastLED.addLeds(leds, NUM_LEDS); 19 | 20 | } 21 | 22 | void loop() { 23 | int degrees; 24 | degrees = getDegree(); 25 | //Serial.print("The angle is:"); 26 | // Serial.println(degrees); 27 | FastLED.clear(1); 28 | if(degrees>0) leds[0] = CRGB::Green; 29 | if(degrees>72) leds[1] = CRGB::Green; 30 | if(degrees>144) leds[2] = CRGB::Green; 31 | if(degrees>216) leds[3] = CRGB::Yellow; 32 | if(degrees>288) leds[4] = CRGB::Red; 33 | if(degrees==360) {leds[0] = CRGB::Red;leds[1] = CRGB::Red;leds[2] = CRGB::Red; leds[3] = CRGB::Red;leds[4] = CRGB::Red;} 34 | 35 | // Turn the LED on, then pause 36 | // leds[0] = CRGB::Red; 37 | // leds[1] = CRGB::Yellow; 38 | // leds[2] = CRGB::Green; 39 | FastLED.show(); 40 | delay(50); 41 | 42 | // Now turn the LED off, then pause 43 | //leds[0] = CRGB::Green; 44 | //leds[1] = CRGB::Blue; 45 | // leds[2] = CRGB::Red; 46 | // FastLED.show(); 47 | //delay(500); 48 | // FastLED.clear(1); 49 | 50 | } 51 | 52 | 53 | int getDegree() 54 | { 55 | int sensor_value = analogRead(ROTARY_ANGLE_SENSOR); 56 | float voltage; 57 | voltage = (float)sensor_value*ADC_REF/1023; 58 | float degrees = (voltage*FULL_ANGLE)/GROVE_VCC; 59 | return degrees; 60 | } 61 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/Multiple/MirroringSample/MirroringSample.ino: -------------------------------------------------------------------------------- 1 | // MirroringSample - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on 2 | // using multiple controllers. In this example, we're going to set up four NEOPIXEL strips on four 3 | // different pins, and show the same thing on all four of them, a simple bouncing dot/cyclon type pattern 4 | 5 | #include "FastLED.h" 6 | 7 | #define NUM_LEDS_PER_STRIP 60 8 | CRGB leds[NUM_LEDS_PER_STRIP]; 9 | 10 | // For mirroring strips, all the "special" stuff happens just in setup. We 11 | // just addLeds multiple times, once for each strip 12 | void setup() { 13 | // tell FastLED there's 60 NEOPIXEL leds on pin 4 14 | FastLED.addLeds(leds, NUM_LEDS_PER_STRIP); 15 | 16 | // tell FastLED there's 60 NEOPIXEL leds on pin 5 17 | FastLED.addLeds(leds, NUM_LEDS_PER_STRIP); 18 | 19 | // tell FastLED there's 60 NEOPIXEL leds on pin 6 20 | FastLED.addLeds(leds, NUM_LEDS_PER_STRIP); 21 | 22 | // tell FastLED there's 60 NEOPIXEL leds on pin 7 23 | FastLED.addLeds(leds, NUM_LEDS_PER_STRIP); 24 | } 25 | 26 | void loop() { 27 | for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) { 28 | // set our current dot to red 29 | leds[i] = CRGB::Red; 30 | FastLED.show(); 31 | // clear our current dot before we move on 32 | leds[i] = CRGB::Black; 33 | delay(100); 34 | } 35 | 36 | for(int i = NUM_LEDS_PER_STRIP-1; i >= 0; i--) { 37 | // set our current dot to red 38 | leds[i] = CRGB::Red; 39 | FastLED.show(); 40 | // clear our current dot before we move on 41 | leds[i] = CRGB::Black; 42 | delay(100); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/Cylon/Cylon.ino: -------------------------------------------------------------------------------- 1 | #include "FastLED.h" 2 | 3 | // How many leds in your strip? 4 | #define NUM_LEDS 64 5 | 6 | // For led chips like Neopixels, which have a data line, ground, and power, you just 7 | // need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, 8 | // ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN 9 | #define DATA_PIN 7 10 | #define CLOCK_PIN 13 11 | 12 | // Define the array of leds 13 | CRGB leds[NUM_LEDS]; 14 | 15 | void setup() { 16 | Serial.begin(57600); 17 | Serial.println("resetting"); 18 | LEDS.addLeds(leds,NUM_LEDS); 19 | LEDS.setBrightness(84); 20 | } 21 | 22 | void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } } 23 | 24 | void loop() { 25 | static uint8_t hue = 0; 26 | Serial.print("x"); 27 | // First slide the led in one direction 28 | for(int i = 0; i < NUM_LEDS; i++) { 29 | // Set the i'th led to red 30 | leds[i] = CHSV(hue++, 255, 255); 31 | // Show the leds 32 | FastLED.show(); 33 | // now that we've shown the leds, reset the i'th led to black 34 | // leds[i] = CRGB::Black; 35 | fadeall(); 36 | // Wait a little bit before we loop around and do it again 37 | delay(10); 38 | } 39 | Serial.print("x"); 40 | 41 | // Now go in the other direction. 42 | for(int i = (NUM_LEDS)-1; i >= 0; i--) { 43 | // Set the i'th led to red 44 | leds[i] = CHSV(hue++, 255, 255); 45 | // Show the leds 46 | FastLED.show(); 47 | // now that we've shown the leds, reset the i'th led to black 48 | // leds[i] = CRGB::Black; 49 | fadeall(); 50 | // Wait a little bit before we loop around and do it again 51 | delay(10); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/extras/RainbowDemo.s65: -------------------------------------------------------------------------------- 1 | ; "Rainbow with glitter" demo 2 | ; for "FastLED6502" 3 | ; 4 | ; Runs on an Apple ][, ][+, //e, or //gs 5 | ; 6 | ; Supports APA102, Adafruit DotStar, 7 | ; LPD8806, and WS2801 LED strips. 8 | ; 9 | ; LED strip connects to game port pins, 10 | ; see FastLED6502.s65 for details. 11 | ; 12 | ; Mark Kriegsman, February 2015 13 | 14 | #define NUM_LEDS 100 15 | #define BRIGHTNESS 64 16 | #define CHIPSET APA102 17 | #define DATA_PIN 14 18 | #define CLOCK_PIN 5 19 | 20 | * = $6000 21 | 22 | #include "FastLED6502.s65" 23 | #include "AppleII.s65" 24 | 25 | gHue .byt 0 26 | gHueDelta .byt 17 27 | gHueSpeed .byt 7 28 | 29 | 30 | Setup 31 | lda #0 32 | sta gHue 33 | 34 | Loop 35 | lda gHue 36 | clc 37 | adc gHueSpeed 38 | sta gHue 39 | ldx gHue 40 | ldy gHueDelta 41 | ; Fill RGB array with HSV rainbow 42 | jsr FastLED_FillRainbow_XY 43 | ; Use master brightness control 44 | lda #BRIGHTNESS 45 | sta FastLED_Brightness 46 | CheckOpenApple 47 | bit OpenApple 48 | bpl CheckSolidApple 49 | ; Add glitter if requested 50 | jsr AddGlitter 51 | CheckSolidApple 52 | bit SolidApple 53 | bpl DoDisplay 54 | ; Pulse brightness if requested 55 | jsr PulseBrightness 56 | DoDisplay 57 | ; This is where the magic happens 58 | jsr FastLED_Show 59 | jmp Loop 60 | 61 | 62 | AddGlitter 63 | ldy #3 64 | MaybeAdd1Glitter 65 | jsr FastLED_Random8 66 | cmp FastLED_NumPixels 67 | bcs SkipThis1Glitter 68 | tax 69 | lda #$FF 70 | sta ledsR,x 71 | sta ledsG,x 72 | sta ledsB,x 73 | SkipThis1Glitter 74 | dey 75 | bne MaybeAdd1Glitter 76 | rts 77 | 78 | 79 | PulseBrightness 80 | lda #13 81 | jsr FastLED_Beat8 82 | clc 83 | adc #12 84 | bcc PulseBright1 85 | lda #$FF 86 | PulseBright1 87 | sta FastLED_Brightness 88 | rts 89 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/Multiple/ParallelOutputDemo/ParallelOutputDemo.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define NUM_LEDS_PER_STRIP 64 4 | // Note: this can be 12 if you're using a teensy 3 and don't mind soldering the pads on the back 5 | #define NUM_STRIPS 16 6 | 7 | CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP]; 8 | 9 | // Pin layouts on the teensy 3/3.1: 10 | // WS2811_PORTD: 2,14,7,8,6,20,21,5 11 | // WS2811_PORTC: 15,22,23,9,10,13,11,12,28,27,29,30 (these last 4 are pads on the bottom of the teensy) 12 | // WS2811_PORTDC: 2,14,7,8,6,20,21,5,15,22,23,9,10,13,11,12 - 16 way parallel 13 | // 14 | // Pin layouts on the due 15 | // WS2811_PORTA: 69,68,61,60,59,100,58,31 (note: pin 100 only available on the digix) 16 | // WS2811_PORTB: 90,91,92,93,94,95,96,97 (note: only available on the digix) 17 | // WS2811_PORTD: 25,26,27,28,14,15,29,11 18 | // 19 | 20 | void setup() { 21 | // LEDS.addLeds(leds, NUM_LEDS_PER_STRIP); 22 | // LEDS.addLeds(leds, NUM_LEDS_PER_STRIP); 23 | // LEDS.addLeds(leds, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip); 24 | LEDS.addLeds(leds, NUM_LEDS_PER_STRIP); 25 | LEDS.setBrightness(32); 26 | } 27 | 28 | void loop() { 29 | static uint8_t hue = 0; 30 | for(int i = 0; i < NUM_STRIPS; i++) { 31 | for(int j = 0; j < NUM_LEDS_PER_STRIP; j++) { 32 | leds[(i*NUM_LEDS_PER_STRIP) + j] = CHSV((32*i) + hue+j,192,255); 33 | } 34 | } 35 | 36 | // Set the first n leds on each strip to show which strip it is 37 | for(int i = 0; i < NUM_STRIPS; i++) { 38 | for(int j = 0; j <= i; j++) { 39 | leds[(i*NUM_LEDS_PER_STRIP) + j] = CRGB::Red; 40 | } 41 | } 42 | 43 | hue++; 44 | 45 | LEDS.show(); 46 | LEDS.delay(10); 47 | } 48 | -------------------------------------------------------------------------------- /Software/Python/bakebit_buzzer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Buzzer Example 4 | # 5 | # 6 | ''' 7 | ## License 8 | 9 | The MIT License (MIT) 10 | 11 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 12 | Copyright (C) 2016 FriendlyARM 13 | 14 | Permission is hereby granted, free of charge, to any person obtaining a copy 15 | of this software and associated documentation files (the "Software"), to deal 16 | in the Software without restriction, including without limitation the rights 17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18 | copies of the Software, and to permit persons to whom the Software is 19 | furnished to do so, subject to the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be included in 22 | all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 30 | THE SOFTWARE. 31 | ''' 32 | 33 | import time 34 | import bakebit 35 | 36 | # Connect the buzzer to digital port D3 37 | # SIG,NC,VCC,GND 38 | buzzer = 3 39 | 40 | bakebit.pinMode(buzzer,"OUTPUT") 41 | 42 | while True: 43 | try: 44 | bakebit.analogWrite(buzzer,127) 45 | time.sleep(2) 46 | bakebit.analogWrite(buzzer,0) 47 | time.sleep(2) 48 | 49 | except KeyboardInterrupt: 50 | bakebit.analogWrite(buzzer,0) 51 | break 52 | 53 | except IOError: 54 | print ("Error") 55 | 56 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/Multiple/MultiArrays/MultiArrays.ino: -------------------------------------------------------------------------------- 1 | // MultiArrays - see https://github.com/FastLED/FastLED/wiki/Multiple-Controller-Examples for more info on 2 | // using multiple controllers. In this example, we're going to set up four NEOPIXEL strips on three 3 | // different pins, each strip getting its own CRGB array to be played with 4 | 5 | #include "FastLED.h" 6 | 7 | #define NUM_LEDS_PER_STRIP 60 8 | CRGB redLeds[NUM_LEDS_PER_STRIP]; 9 | CRGB greenLeds[NUM_LEDS_PER_STRIP]; 10 | CRGB blueLeds[NUM_LEDS_PER_STRIP]; 11 | 12 | // For mirroring strips, all the "special" stuff happens just in setup. We 13 | // just addLeds multiple times, once for each strip 14 | void setup() { 15 | // tell FastLED there's 60 NEOPIXEL leds on pin 10 16 | FastLED.addLeds(redLeds, NUM_LEDS_PER_STRIP); 17 | 18 | // tell FastLED there's 60 NEOPIXEL leds on pin 11 19 | FastLED.addLeds(greenLeds, NUM_LEDS_PER_STRIP); 20 | 21 | // tell FastLED there's 60 NEOPIXEL leds on pin 12 22 | FastLED.addLeds(blueLeds, NUM_LEDS_PER_STRIP); 23 | 24 | } 25 | 26 | void loop() { 27 | for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) { 28 | // set our current dot to red, green, and blue 29 | redLeds[i] = CRGB::Red; 30 | greenLeds[i] = CRGB::Green; 31 | blueLeds[i] = CRGB::Blue; 32 | FastLED.show(); 33 | // clear our current dot before we move on 34 | redLeds[i] = CRGB::Black; 35 | greenLeds[i] = CRGB::Black; 36 | blueLeds[i] = CRGB::Blue; 37 | delay(100); 38 | } 39 | 40 | for(int i = NUM_LEDS_PER_STRIP-1; i >= 0; i--) { 41 | // set our current dot to red, green, and blue 42 | redLeds[i] = CRGB::Red; 43 | greenLeds[i] = CRGB::Green; 44 | blueLeds[i] = CRGB::Blue; 45 | FastLED.show(); 46 | // clear our current dot before we move on 47 | redLeds[i] = CRGB::Black; 48 | greenLeds[i] = CRGB::Black; 49 | blueLeds[i] = CRGB::Blue; 50 | delay(100); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Software/Python/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python #!/usr/bin/env python 2 | # 3 | # BakeBit Python Setup 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 6 | # 7 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 8 | # 9 | ''' 10 | ## License 11 | 12 | The MIT License (MIT) 13 | 14 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 15 | Copyright (C) 2016 FriendlyARM 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | ''' 35 | # To install the BakeBit library systemwide, use: sudo python setup.py install 36 | import setuptools 37 | setuptools.setup( 38 | name="bakebit", 39 | description="Drivers and examples for using the BakeBit in Python", 40 | author="FriendlyARM", 41 | url="http://wiki.friendlyarm.com/bakebit", 42 | py_modules=['bakebit'], 43 | #install_requires=open('requirements.txt').readlines(), 44 | ) 45 | -------------------------------------------------------------------------------- /Software/Python/bakebit_button.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit Button (http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Button) 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 6 | # 7 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 8 | # 9 | ''' 10 | ## License 11 | 12 | The MIT License (MIT) 13 | 14 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 15 | Copyright (C) 2016 FriendlyARM 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | ''' 35 | import time 36 | import bakebit 37 | 38 | # Connect the BakeBit Button to digital port D3 39 | # SIG,NC,VCC,GND 40 | button = 3 41 | 42 | bakebit.pinMode(button,"INPUT") 43 | 44 | while True: 45 | try: 46 | print(bakebit.digitalRead(button)) 47 | time.sleep(.5) 48 | 49 | except IOError: 50 | print ("Error") 51 | -------------------------------------------------------------------------------- /Software/Python/bakebit_servo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit Servo 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 6 | # 7 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 8 | # 9 | ''' 10 | ## License 11 | 12 | The MIT License (MIT) 13 | 14 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 15 | Copyright (C) 2016 FriendlyARM 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | ''' 35 | 36 | import time 37 | import bakebit 38 | 39 | # Connect the servo to digital port D5 40 | # SIG,NC,VCC,GND 41 | servo = 5 42 | bakebit.bakeBitServo_Attach(servo) 43 | for angle in range(0,181): 44 | try: 45 | bakebit.bakeBitServo_Write(servo,angle) 46 | time.sleep(.2) 47 | except KeyboardInterrupt: 48 | break 49 | except IOError: 50 | print ("Error") 51 | 52 | bakebit.bakeBitServo_Detach(servo) 53 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/DS1307.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | // Function: Header file for DS1307 3 | // Hardware: Grove - RTC 4 | // Arduino IDE: Arduino-1.0 5 | // Author: FrankieChu 6 | // Date: Jan 19,2013 7 | // Version: v1.0 8 | // by www.seeedstudio.com 9 | // 10 | // This library is free software; you can redistribute it and/or 11 | // modify it under the terms of the GNU Lesser General Public 12 | // License as published by the Free Software Foundation; either 13 | // version 2.1 of the License, or (at your option) any later version. 14 | // 15 | // This library is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 | // Lesser General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU Lesser General Public 21 | // License along with this library; if not, write to the Free Software 22 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | // 24 | /****************************************************************************/ 25 | 26 | #ifndef __DS1307_H__ 27 | #define __DS1307_H__ 28 | 29 | #include 30 | 31 | #define DS1307_I2C_ADDRESS 0x68 32 | 33 | #define MON 1 34 | #define TUE 2 35 | #define WED 3 36 | #define THU 4 37 | #define FRI 5 38 | #define SAT 6 39 | #define SUN 7 40 | 41 | class DS1307 42 | { 43 | private: 44 | uint8_t decToBcd(uint8_t val); 45 | uint8_t bcdToDec(uint8_t val); 46 | 47 | public: 48 | void begin(); 49 | void startClock(void); 50 | void stopClock(void); 51 | void setTime(void); 52 | void getTime(void); 53 | void fillByHMS(uint8_t _hour, uint8_t _minute, uint8_t _second); 54 | void fillByYMD(uint16_t _year, uint8_t _month, uint8_t _day); 55 | void fillDayOfWeek(uint8_t _dow); 56 | uint8_t second; 57 | uint8_t minute; 58 | uint8_t hour; 59 | uint8_t dayOfWeek;// day of week, 1 = Monday 60 | uint8_t dayOfMonth; 61 | uint8_t month; 62 | uint16_t year; 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/fastled_progmem.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FL_PROGMEM_H 2 | #define __INC_FL_PROGMEM_H 3 | 4 | ///@file fastled_progmem.h 5 | /// wrapper definitions to allow seamless use of PROGMEM in environmens that have it 6 | 7 | FASTLED_NAMESPACE_BEGIN 8 | 9 | // Compatibility layer for devices that do or don't 10 | // have "PROGMEM" and the associated pgm_ accessors. 11 | // 12 | // If a platform supports PROGMEM, it should define 13 | // "FASTLED_USE_PROGMEM" as 1, otherwise FastLED will 14 | // fall back to NOT using PROGMEM. 15 | // 16 | // Whether or not pgmspace.h is #included is separately 17 | // controllable by FASTLED_INCLUDE_PGMSPACE, if needed. 18 | 19 | 20 | // If FASTLED_USE_PROGMEM is 1, we'll map FL_PROGMEM 21 | // and the FL_PGM_* accessors to the Arduino equivalents. 22 | #if FASTLED_USE_PROGMEM == 1 23 | #ifndef FASTLED_INCLUDE_PGMSPACE 24 | #define FASTLED_INCLUDE_PGMSPACE 1 25 | #endif 26 | 27 | #if FASTLED_INCLUDE_PGMSPACE == 1 28 | #include 29 | #endif 30 | 31 | #define FL_PROGMEM PROGMEM 32 | 33 | // Note: only the 'near' memory wrappers are provided. 34 | // If you're using 'far' memory, you already have 35 | // portability issues to work through, but you could 36 | // add more support here if needed. 37 | #define FL_PGM_READ_BYTE_NEAR(x) (pgm_read_byte_near(x)) 38 | #define FL_PGM_READ_WORD_NEAR(x) (pgm_read_word_near(x)) 39 | #define FL_PGM_READ_DWORD_NEAR(x) (pgm_read_dword_near(x)) 40 | 41 | // Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734 42 | #ifdef FASTLED_AVR 43 | #ifdef PROGMEM 44 | #undef PROGMEM 45 | #define PROGMEM __attribute__((section(".progmem.data"))) 46 | #endif 47 | #endif 48 | 49 | #else 50 | // If FASTLED_USE_PROGMEM is 0 or undefined, 51 | // we'll use regular memory (RAM) access. 52 | 53 | //empty PROGMEM simulation 54 | #define FL_PROGMEM 55 | #define FL_PGM_READ_BYTE_NEAR(x) (*((const uint8_t*)(x))) 56 | #define FL_PGM_READ_WORD_NEAR(x) (*((const uint16_t*)(x))) 57 | #define FL_PGM_READ_DWORD_NEAR(x) (*((const uint32_t*)(x))) 58 | 59 | #endif 60 | 61 | 62 | FASTLED_NAMESPACE_END 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Software/Python/bakebit_ultrasonic.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit Ultrasonic Ranger (http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Ultrasonic_Ranger) 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 6 | # 7 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 8 | # 9 | ''' 10 | ## License 11 | 12 | The MIT License (MIT) 13 | 14 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 15 | Copyright (C) 2016 FriendlyARM 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | ''' 35 | 36 | import bakebit 37 | 38 | # Connect the BakeBit Ultrasonic Ranger to digital port D4 39 | # SIG,NC,VCC,GND 40 | ultrasonic_ranger = 4 41 | 42 | while True: 43 | try: 44 | # Read distance value from Ultrasonic 45 | print(bakebit.ultrasonicRead(ultrasonic_ranger)) 46 | 47 | except TypeError: 48 | print ("Error") 49 | except IOError: 50 | print ("Error") 51 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/AnalogOutput/AnalogOutput.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Example showing how to use FastLED color functions 4 | // even when you're NOT using a "pixel-addressible" smart LED strip. 5 | // 6 | // This example is designed to control an "analog" RGB LED strip 7 | // (or a single RGB LED) being driven by Arduino PWM output pins. 8 | // So this code never calls FastLED.addLEDs() or FastLED.show(). 9 | // 10 | // This example illustrates one way you can use just the portions 11 | // of FastLED that you need. In this case, this code uses just the 12 | // fast HSV color conversion code. 13 | // 14 | // In this example, the RGB values are output on three separate 15 | // 'analog' PWM pins, one for red, one for green, and one for blue. 16 | 17 | #define REDPIN 5 18 | #define GREENPIN 6 19 | #define BLUEPIN 3 20 | 21 | // showAnalogRGB: this is like FastLED.show(), but outputs on 22 | // analog PWM output pins instead of sending data to an intelligent, 23 | // pixel-addressable LED strip. 24 | // 25 | // This function takes the incoming RGB values and outputs the values 26 | // on three analog PWM output pins to the r, g, and b values respectively. 27 | void showAnalogRGB( const CRGB& rgb) 28 | { 29 | analogWrite(REDPIN, rgb.r ); 30 | analogWrite(GREENPIN, rgb.g ); 31 | analogWrite(BLUEPIN, rgb.b ); 32 | } 33 | 34 | 35 | 36 | // colorBars: flashes Red, then Green, then Blue, then Black. 37 | // Helpful for diagnosing if you've mis-wired which is which. 38 | void colorBars() 39 | { 40 | showAnalogRGB( CRGB::Red ); delay(500); 41 | showAnalogRGB( CRGB::Green ); delay(500); 42 | showAnalogRGB( CRGB::Blue ); delay(500); 43 | showAnalogRGB( CRGB::Black ); delay(500); 44 | } 45 | 46 | void loop() 47 | { 48 | static uint8_t hue; 49 | hue = hue + 1; 50 | // Use FastLED automatic HSV->RGB conversion 51 | showAnalogRGB( CHSV( hue, 255, 255) ); 52 | 53 | delay(20); 54 | } 55 | 56 | 57 | void setup() { 58 | pinMode(REDPIN, OUTPUT); 59 | pinMode(GREENPIN, OUTPUT); 60 | pinMode(BLUEPIN, OUTPUT); 61 | 62 | // Flash the "hello" color sequence: R, G, B, black. 63 | colorBars(); 64 | } 65 | 66 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/colorpalettes.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_COLORPALETTES_H 2 | #define __INC_COLORPALETTES_H 3 | 4 | #include "colorutils.h" 5 | 6 | ///@file colorpalettes.h 7 | /// contains definitions for the predefined color palettes supplied by FastLED. 8 | 9 | FASTLED_NAMESPACE_BEGIN 10 | 11 | ///@defgroup Colorpalletes Pre-defined color palletes 12 | /// These schemes are all declared as "PROGMEM", meaning 13 | /// that they won't take up SRAM on AVR chips until used. 14 | /// Furthermore, the compiler won't even include these 15 | /// in your PROGMEM (flash) storage unless you specifically 16 | /// use each one, so you only 'pay for' those you actually use. 17 | 18 | ///@{ 19 | 20 | /// Cloudy color pallete 21 | extern const TProgmemRGBPalette16 CloudColors_p FL_PROGMEM; 22 | /// Lava colors 23 | extern const TProgmemRGBPalette16 LavaColors_p FL_PROGMEM; 24 | /// Ocean colors, blues and whites 25 | extern const TProgmemRGBPalette16 OceanColors_p FL_PROGMEM; 26 | /// Forest colors, greens 27 | extern const TProgmemRGBPalette16 ForestColors_p FL_PROGMEM; 28 | 29 | /// HSV Rainbow 30 | extern const TProgmemRGBPalette16 RainbowColors_p FL_PROGMEM; 31 | 32 | #define RainbowStripesColors_p RainbowStripeColors_p 33 | /// HSV Rainbow colors with alternatating stripes of black 34 | extern const TProgmemRGBPalette16 RainbowStripeColors_p FL_PROGMEM; 35 | 36 | /// HSV color ramp: blue purple ping red orange yellow (and back) 37 | /// Basically, everything but the greens, which tend to make 38 | /// people's skin look unhealthy. This palette is good for 39 | /// lighting at a club or party, where it'll be shining on people. 40 | extern const TProgmemRGBPalette16 PartyColors_p FL_PROGMEM; 41 | 42 | /// Approximate "black body radiation" palette, akin to 43 | /// the FastLED 'HeatColor' function. 44 | /// Recommend that you use values 0-240 rather than 45 | /// the usual 0-255, as the last 15 colors will be 46 | /// 'wrapping around' from the hot end to the cold end, 47 | /// which looks wrong. 48 | extern const TProgmemRGBPalette16 HeatColors_p FL_PROGMEM; 49 | 50 | 51 | DECLARE_GRADIENT_PALETTE( Rainbow_gp); 52 | 53 | FASTLED_NAMESPACE_END 54 | 55 | ///@} 56 | #endif 57 | -------------------------------------------------------------------------------- /Software/Python/bakebit_128_64_oled_image.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit example for the basic functions of BakeBit 128x64 OLED (http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_OLED_128x64) 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. 6 | # You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 7 | # 8 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 9 | # 10 | ''' 11 | ## License 12 | 13 | The MIT License (MIT) 14 | 15 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 16 | Copyright (C) 2016 FriendlyARM 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy 19 | of this software and associated documentation files (the "Software"), to deal 20 | in the Software without restriction, including without limitation the rights 21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | copies of the Software, and to permit persons to whom the Software is 23 | furnished to do so, subject to the following conditions: 24 | 25 | The above copyright notice and this permission notice shall be included in 26 | all copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 34 | THE SOFTWARE. 35 | ''' 36 | 37 | import bakebit_128_64_oled as oled 38 | from PIL import Image 39 | from PIL import ImageFont 40 | from PIL import ImageDraw 41 | 42 | oled.init() #initialze SEEED OLED display 43 | 44 | oled.clearDisplay() #clear the screen and set start position to top left corner 45 | oled.setNormalDisplay() #Set display to normal mode (i.e non-inverse mode) 46 | oled.setHorizontalMode() 47 | 48 | image = Image.open('friendllyelec.png').convert('1') 49 | oled.drawImage(image) 50 | 51 | -------------------------------------------------------------------------------- /Software/Python/bakebit_128_32_oled_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit example for the basic functions of BakeBit 128x32 OLED 4 | # 5 | # The BakeBit connects the NanoPi NEO (NEO2) and BakeBit sensors. 6 | # You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 7 | # 8 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 9 | # 10 | ''' 11 | ## License 12 | 13 | The MIT License (MIT) 14 | 15 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 16 | Copyright (C) 2016 FriendlyARM 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy 19 | of this software and associated documentation files (the "Software"), to deal 20 | in the Software without restriction, including without limitation the rights 21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | copies of the Software, and to permit persons to whom the Software is 23 | furnished to do so, subject to the following conditions: 24 | 25 | The above copyright notice and this permission notice shall be included in 26 | all copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 34 | THE SOFTWARE. 35 | ''' 36 | 37 | import bakebit_128_32_oled as oled 38 | 39 | oled.init() #initialze SEEED OLED display 40 | 41 | oled.clearDisplay() #clear the screen and set start position to top left corner 42 | oled.setNormalDisplay() #Set display to normal mode (i.e non-inverse mode) 43 | oled.setPageMode() #Set addressing mode to Page Mode 44 | 45 | # Seems the 128x32 only have 4 rows. 46 | texts = ["1234567890123456", "abcdefghijk", "ABCDEFGHIJK", "~!@#$%^&*()_+;',./:" ] 47 | 48 | for i in range(4): 49 | oled.setTextXY(0,i) #Set the cursor to Xth Column, Yth Row 50 | oled.putString(str(i) + " " + texts[i]) #Print the String 51 | 52 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/NoisePlayground/NoisePlayground.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define kMatrixWidth 16 4 | #define kMatrixHeight 16 5 | 6 | #define NUM_LEDS (kMatrixWidth * kMatrixHeight) 7 | // Param for different pixel layouts 8 | #define kMatrixSerpentineLayout true 9 | 10 | // led array 11 | CRGB leds[kMatrixWidth * kMatrixHeight]; 12 | 13 | // x,y, & time values 14 | uint32_t x,y,v_time,hue_time,hxy; 15 | 16 | // Play with the values of the variables below and see what kinds of effects they 17 | // have! More octaves will make things slower. 18 | 19 | // how many octaves to use for the brightness and hue functions 20 | uint8_t octaves=1; 21 | uint8_t hue_octaves=3; 22 | 23 | // the 'distance' between points on the x and y axis 24 | int xscale=57771; 25 | int yscale=57771; 26 | 27 | // the 'distance' between x/y points for the hue noise 28 | int hue_scale=1; 29 | 30 | // how fast we move through time & hue noise 31 | int time_speed=1111; 32 | int hue_speed=31; 33 | 34 | // adjust these values to move along the x or y axis between frames 35 | int x_speed=331; 36 | int y_speed=1111; 37 | 38 | void loop() { 39 | // fill the led array 2/16-bit noise values 40 | fill_2dnoise16(LEDS.leds(), kMatrixWidth, kMatrixHeight, kMatrixSerpentineLayout, 41 | octaves,x,xscale,y,yscale,v_time, 42 | hue_octaves,hxy,hue_scale,hxy,hue_scale,hue_time, false); 43 | 44 | LEDS.show(); 45 | 46 | // adjust the intra-frame time values 47 | x += x_speed; 48 | y += y_speed; 49 | v_time += time_speed; 50 | hue_time += hue_speed; 51 | // delay(50); 52 | } 53 | 54 | 55 | void setup() { 56 | // initialize the x/y and time values 57 | random16_set_seed(8934); 58 | random16_add_entropy(analogRead(3)); 59 | 60 | Serial.begin(57600); 61 | Serial.println("resetting!"); 62 | 63 | delay(3000); 64 | LEDS.addLeds(leds,NUM_LEDS); 65 | LEDS.setBrightness(96); 66 | 67 | hxy = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16(); 68 | x = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16(); 69 | y = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16(); 70 | v_time = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16(); 71 | hue_time = (uint32_t)((uint32_t)random16() << 16) + (uint32_t)random16(); 72 | 73 | } 74 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/PORTING.md: -------------------------------------------------------------------------------- 1 | =New platform porting guide= 2 | 3 | == Setting up the basic files/folders == 4 | 5 | * Create platform directory (e.g. platforms/arm/kl26) 6 | * Create configuration header led_sysdefs_arm_kl26.h: 7 | * Define platform flags (like FASTLED_ARM/FASTLED_TEENSY) 8 | * Define configuration parameters re: interrupts, or clock doubling 9 | * Include extar system header files if needed 10 | * Create main platform include, fastled_arm_kl26.h 11 | * Include the various other header files as needed 12 | * Modify led_sysdefs.h to conditionally include platform sysdefs header file 13 | * Modify platforms.h to conditionally include platform fastled header 14 | 15 | == Porting fastpin.h == 16 | 17 | The heart of the FastLED library is the fast pin accesss. This is a templated class that provides 1-2 cycle pin access, bypassing digital write and other such things. As such, this will usually be the first bit of the library that you will want to port when moving to a new platform. Once you have FastPIN up and running then you can do some basic work like testing toggles or running bit-bang'd SPI output. 18 | 19 | There's two low level FastPin classes. There's the base FastPIN template class, and then there is FastPinBB which is for bit-banded access on those MCUs that support bitbanding. Note that the bitband class is optional and primarily useful in the implementation of other functionality internal to the platform. This file is also where you would do the pin to port/bit mapping defines. 20 | 21 | Explaining how the macros work and should be used is currently beyond the scope of this document. 22 | 23 | == Porting fastspi.h == 24 | 25 | This is where you define the low level interface to the hardware SPI system (including a writePixels method that does a bunch of housekeeping for writing led data). Use the fastspi_nop.h file as a reference for the methods that need to be implemented. There are ofteh other useful methods that can help with the internals of the SPI code, I recommend taking a look at how the various platforms implement their SPI classes. 26 | 27 | == Porting clockless.h == 28 | 29 | This is where you define the code for the clockless controllers. Across ARM platforms this will usually be fairly similar - though different arm platforms will have different clock sources that you can/should use. 30 | -------------------------------------------------------------------------------- /Software/Python/bakebit_128_64_oled_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit example for the basic functions of BakeBit 128x64 OLED (http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_OLED_128x64) 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. 6 | # You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 7 | # 8 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 9 | # 10 | ''' 11 | ## License 12 | 13 | The MIT License (MIT) 14 | 15 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 16 | Copyright (C) 2016 FriendlyARM 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy 19 | of this software and associated documentation files (the "Software"), to deal 20 | in the Software without restriction, including without limitation the rights 21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | copies of the Software, and to permit persons to whom the Software is 23 | furnished to do so, subject to the following conditions: 24 | 25 | The above copyright notice and this permission notice shall be included in 26 | all copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 34 | THE SOFTWARE. 35 | ''' 36 | 37 | import bakebit_128_64_oled as oled 38 | 39 | oled.init() #initialze SEEED OLED display 40 | 41 | oled.clearDisplay() #clear the screen and set start position to top left corner 42 | oled.setNormalDisplay() #Set display to normal mode (i.e non-inverse mode) 43 | oled.setPageMode() #Set addressing mode to Page Mode 44 | 45 | texts = ["BakeBit Demo", "1234567890123456", "abcdefghijk", "ABCDEFGHIJK", "~!@#$%^&*()_+;',./:", "----------------", "by", "FriendlyElec" ] 46 | 47 | for i in range(8): 48 | oled.setTextXY(0,i) #Set the cursor to Xth Page, Yth Column 49 | oled.putString(texts[i]) #Print the String 50 | -------------------------------------------------------------------------------- /Software/Python/bakebit_thumb_joystick.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit Thumb Joystick (http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_JoyStick) 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 6 | # 7 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 8 | # 9 | ''' 10 | ## License 11 | 12 | The MIT License (MIT) 13 | 14 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 15 | Copyright (C) 2016 FriendlyARM 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | ''' 35 | 36 | import time 37 | import bakebit 38 | 39 | # Connect the BakeBit Thumb Joystick to analog port A0 40 | # If you wish to connect two joysticks, use ports A0 and A2 (skip A1) 41 | 42 | # Uses two pins - one for the X axis and one for the Y axis 43 | # This configuration means you are using port A0 44 | xPin = 0 45 | yPin = 1 46 | bakebit.pinMode(xPin,"INPUT") 47 | bakebit.pinMode(yPin,"INPUT") 48 | 49 | while True: 50 | try: 51 | # Get X/Y coordinates 52 | x = bakebit.analogRead(xPin) 53 | y = bakebit.analogRead(yPin) 54 | print("x =", x, " y =", y) 55 | time.sleep(.5) 56 | 57 | except IOError: 58 | print ("Error") 59 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/ChainableLED.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2012 Paulo Marques (pjp.marques@gmail.com) 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | this software and associated documentation files (the "Software"), to deal in 6 | the Software without restriction, including without limitation the rights to 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | the Software, and to permit persons to whom the Software is furnished to do so, 9 | subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | /* 23 | * Library for controlling a chain of RGB LEDs based on the P9813 protocol. 24 | * E.g., supports the Grove Chainable RGB LED product. 25 | * 26 | * Information about the P9813 protocol obtained from: 27 | * http://www.seeedstudio.com/wiki/index.php?title=Twig_-_Chainable_RGB_LED 28 | */ 29 | 30 | 31 | 32 | #ifndef __ChainableLED_h__ 33 | #define __ChainableLED_h__ 34 | 35 | #include "Arduino.h" 36 | 37 | #define _CL_RED 0 38 | #define _CL_GREEN 1 39 | #define _CL_BLUE 2 40 | #define _CLK_PULSE_DELAY 20 41 | 42 | class ChainableLED 43 | { 44 | public: 45 | // ChainableLED(byte clk_pin, byte data_pin, byte number_of_leds); 46 | void begin(byte clk_pin, byte data_pin, byte number_of_leds); 47 | // ~begin(); 48 | 49 | void setColorRGB(byte led, byte red, byte green, byte blue); 50 | //void setColorHSB(byte led, float hue, float saturation, float brightness); 51 | 52 | byte getNumLeds(); 53 | bool ready(); 54 | 55 | private: 56 | byte _clk_pin; 57 | byte _data_pin; 58 | byte _num_leds; 59 | 60 | byte* _led_state; 61 | 62 | void clk(void); 63 | void sendByte(byte b); 64 | void sendColor(byte red, byte green, byte blue); 65 | }; 66 | 67 | #endif 68 | 69 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/power_mgt.h: -------------------------------------------------------------------------------- 1 | #ifndef POWER_MGT_H 2 | #define POWER_MGT_H 3 | 4 | #include "pixeltypes.h" 5 | 6 | FASTLED_NAMESPACE_BEGIN 7 | 8 | ///@defgroup Power Power management functions 9 | /// functions used to limit the amount of power used by FastLED 10 | 11 | // Power Control setup functions 12 | // 13 | // Example: 14 | // set_max_power_in_volts_and_milliamps( 5, 400); 15 | // 16 | 17 | /// Set the maximum power used in milliamps for a given voltage 18 | void set_max_power_in_volts_and_milliamps( uint8_t volts, uint32_t milliamps); 19 | /// Set the maximum power used in watts 20 | void set_max_power_in_milliwatts( uint32_t powerInmW); 21 | 22 | /// Select a ping with an led that will be flashed to indicate that power management 23 | /// is pulling down the brightness 24 | void set_max_power_indicator_LED( uint8_t pinNumber); // zero = no indicator LED 25 | 26 | 27 | // Power Control 'show' and 'delay' functions 28 | // 29 | // These are drop-in replacements for FastLED.show() and FastLED.delay() 30 | // In order to use these, you have to actually replace your calls to 31 | // FastLED.show() and FastLED.delay() with these two functions. 32 | // 33 | // Example: 34 | // // was: FastLED.show(); 35 | // // now is: 36 | // show_at_max_brightness_for_power(); 37 | // 38 | 39 | /// Similar to FastLED.show, but pre-adjusts brightness to keep below the power 40 | /// threshold. 41 | void show_at_max_brightness_for_power(); 42 | /// Similar to FastLED.delay, but pre-adjusts brightness to keep below the power 43 | /// threshold. 44 | void delay_at_max_brightness_for_power( uint16_t ms); 45 | 46 | 47 | // Power Control internal helper functions 48 | 49 | /// calculate_unscaled_power_mW tells you how many milliwatts the current 50 | /// LED data would draw at brightness = 255. 51 | /// 52 | uint32_t calculate_unscaled_power_mW( const CRGB* ledbuffer, uint16_t numLeds); 53 | 54 | /// calculate_max_brightness_for_power_mW tells you the highest brightness 55 | /// level you can use and still stay under the specified power budget. It 56 | /// takes a 'target brightness' which is the brightness you'd ideally like 57 | /// to use. The result from this function will be no higher than the 58 | /// target_brightess you supply, but may be lower. 59 | uint8_t calculate_max_brightness_for_power_mW( uint8_t target_brightness, uint32_t max_power_mW); 60 | 61 | FASTLED_NAMESPACE_END 62 | ///@} 63 | // POWER_MGT_H 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/MMA7660.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | // Function: Header file for class MMC7660 3 | // Hardware: Grove - 3-Axis Digital Accelerometer(±1.5g) 4 | // Arduino IDE: Arduino-1.0 5 | // Author: Frankie.Chu 6 | // Date: Jan 10,2013 7 | // Version: v0.9b 8 | // by www.seeedstudio.com 9 | // 10 | // 11 | // This library is free software; you can redistribute it and/or 12 | // modify it under the terms of the GNU Lesser General Public 13 | // License as published by the Free Software Foundation; either 14 | // version 2.1 of the License, or (at your option) any later version. 15 | // 16 | // This library is distributed in the hope that it will be useful, 17 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | // Lesser General Public License for more details. 20 | // 21 | // You should have received a copy of the GNU Lesser General Public 22 | // License along with this library; if not, write to the Free Software 23 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 | // 25 | /*******************************************************************************/ 26 | #ifndef __MMC7660_H__ 27 | #define __MMC7660_H__ 28 | 29 | #define MMA7660_ADDR 0x4c 30 | 31 | #define MMA7660_X 0x00 32 | #define MMA7660_Y 0x01 33 | #define MMA7660_Z 0x02 34 | #define MMA7660_TILT 0x03 35 | #define MMA7660_SRST 0x04 36 | #define MMA7660_SPCNT 0x05 37 | #define MMA7660_INTSU 0x06 38 | #define MMA7660_MODE 0x07 39 | #define MMA7660_STAND_BY 0x00 40 | #define MMA7660_ACTIVE 0x01 41 | #define MMA7660_SR 0x08 //sample rate register 42 | #define AUTO_SLEEP_120 0X00//120 sample per second 43 | #define AUTO_SLEEP_64 0X01 44 | #define AUTO_SLEEP_32 0X02 45 | #define AUTO_SLEEP_16 0X03 46 | #define AUTO_SLEEP_8 0X04 47 | #define AUTO_SLEEP_4 0X05 48 | #define AUTO_SLEEP_2 0X06 49 | #define AUTO_SLEEP_1 0X07 50 | #define MMA7660_PDET 0x09 51 | #define MMA7660_PD 0x0A 52 | class MMA7660 53 | { 54 | private: 55 | void write(uint8_t _register, uint8_t _data); 56 | uint8_t read(uint8_t _register); 57 | public: 58 | void init(); 59 | void setMode(uint8_t mode); 60 | void setSampleRate(uint8_t rate); 61 | unsigned char getXYZ(int8_t *x,int8_t *y,int8_t *z); 62 | unsigned char getAcceleration(float *ax,float *ay,float *az); 63 | }; 64 | 65 | #endif 66 | 67 | 68 | -------------------------------------------------------------------------------- /Software/Python/bakebit_sound_sensor.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit Sound Sensor and the BakeBit LED 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 6 | # 7 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 8 | # 9 | ''' 10 | ## License 11 | 12 | The MIT License (MIT) 13 | 14 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 15 | Copyright (C) 2016 FriendlyARM 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | ''' 35 | 36 | import time 37 | import bakebit 38 | 39 | # Connect the BakeBit Sound Sensor to analog port A0 40 | # SIG,NC,VCC,GND 41 | sound_sensor = 0 42 | 43 | # Connect the BakeBit LED to digital port D5 44 | # SIG,NC,VCC,GND 45 | led = 5 46 | 47 | bakebit.pinMode(sound_sensor,"INPUT") 48 | bakebit.pinMode(led,"OUTPUT") 49 | 50 | # The threshold to turn the led on 400.00 * 5 / 1024 = 1.95v 51 | threshold_value = 400 52 | 53 | while True: 54 | try: 55 | # Read the sound level 56 | sensor_value = bakebit.analogRead(sound_sensor) 57 | 58 | # If loud, illuminate LED, otherwise dim 59 | if sensor_value > threshold_value: 60 | bakebit.digitalWrite(led,1) 61 | else: 62 | bakebit.digitalWrite(led,0) 63 | 64 | print("sensor_value = %d" %sensor_value) 65 | time.sleep(.2) 66 | 67 | except IOError: 68 | print ("Error") 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## **BakeBit** 2 | 3 | [English](https://github.com/friendlyarm/BakeBit) 4 | [汉语](https://github.com/friendlyarm/BakeBit/blob/master/README.zh_CN.md) 5 | 6 | 7 | BakeBit is an open source platform for connecting BakeBit Sensors to the NanoPi NEO/NEO2. It is based on the GrovePi. 8 | 9 | Currently supported boards: NanoPi NEO, NanoPi NEO2, NanoPi NEO Air. 10 | 11 | ## Introduction 12 | 13 | The code work well on armbian or friendlycore (ubuntu-core) with Python 3.x 14 | 15 | I abandon using PIP(Python Package Installer) when installing in install.sh, but not in install-compatible.sh, and take full advantage of APT with the latest release packages of distribution. 16 | 17 | The original implementation was based on Python2, thanks to [CuitGGyy](https://github.com/CuitGGyy/BakeBit) for porting it to Python 3.x environment. 18 | 19 | ## Installtion 20 | 21 | #### FriendlyCore Xenial / Armbian Stretch / Ubuntu Core Xenial 22 | 23 | ``` 24 | # git clone --depth=1 https://github.com/friendlyarm/BakeBit.git 25 | # cd BakeBit 26 | # sudo -H ./install.sh 27 | ``` 28 | 29 | #### FriendlyCore Focal / Armbian Buster / Ubuntu Core Bionic 30 | 31 | ``` 32 | # git clone --depth=1 https://github.com/friendlyarm/BakeBit.git 33 | # cd BakeBit 34 | # sudo -H ./install-compat.sh 35 | ``` 36 | 37 | The demo will automatically start at the next reboot. 38 | 39 | 40 | ## License 41 | 42 | The MIT License (MIT) 43 | 44 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 45 | Copyright (C) 2016 FriendlyARM 46 | 47 | Permission is hereby granted, free of charge, to any person obtaining a copy 48 | of this software and associated documentation files (the "Software"), to deal 49 | in the Software without restriction, including without limitation the rights 50 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 51 | copies of the Software, and to permit persons to whom the Software is 52 | furnished to do so, subject to the following conditions: 53 | 54 | The above copyright notice and this permission notice shall be included in 55 | all copies or substantial portions of the Software. 56 | 57 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 58 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 59 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 60 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 61 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 62 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 63 | THE SOFTWARE. 64 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/fastspi_nop.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTSPI_NOP_H 2 | #define __INC_FASTSPI_NOP_H 3 | 4 | FASTLED_NAMESPACE_BEGIN 5 | 6 | /// A nop/stub class, mostly to show the SPI methods that are needed/used by the various SPI chipset implementations. Should 7 | /// be used as a definition for the set of methods that the spi implementation classes should use (since C++ doesn't support the 8 | /// idea of interfaces - it's possible this could be done with virtual classes, need to decide if i want that overhead) 9 | template 10 | class NOPSPIOutput { 11 | Selectable *m_pSelect; 12 | 13 | public: 14 | NOPSPIOutput() { m_pSelect = NULL; } 15 | NOPSPIOutput(Selectable *pSelect) { m_pSelect = pSelect; } 16 | 17 | /// set the object representing the selectable 18 | void setSelect(Selectable *pSelect) { m_pSelect = pSelect; } 19 | 20 | /// initialize the SPI subssytem 21 | void init() { /* TODO */ } 22 | 23 | /// latch the CS select 24 | void select() { /* TODO */ } 25 | 26 | /// release the CS select 27 | void release() { /* TODO */ } 28 | 29 | /// wait until all queued up data has been written 30 | void waitFully(); 31 | 32 | /// not the most efficient mechanism in the world - but should be enough for sm16716 and friends 33 | template inline static void writeBit(uint8_t b) { /* TODO */ 34 | 35 | /// write a byte out via SPI (returns immediately on writing register) 36 | void writeByte(uint8_t b) { /* TODO */ } 37 | /// write a word out via SPI (returns immediately on writing register) 38 | void writeWord(uint16_t w) { /* TODO */ } 39 | 40 | /// A raw set of writing byte values, assumes setup/init/waiting done elsewhere (static for use by adjustment classes) 41 | static void writeBytesValueRaw(uint8_t value, int len) { /* TODO */ } 42 | 43 | /// A full cycle of writing a value for len bytes, including select, release, and waiting 44 | void writeBytesValue(uint8_t value, int len) { /* TODO */ } 45 | 46 | /// A full cycle of writing a raw block of data out, including select, release, and waiting 47 | void writeBytes(uint8_t *data, int len) { /* TODO */ } 48 | 49 | /// write a single bit out, which bit from the passed in byte is determined by template parameter 50 | template inline static void writeBit(uint8_t b) { /* TODO */ } 51 | 52 | /// write out pixel data from the given PixelController object 53 | template void writePixels(PixelController pixels) { /* TODO */ } 54 | 55 | }; 56 | 57 | FASTLED_NAMESPACE_END 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/k20/smartmatrix_t3.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_SMARTMATRIX_T3_H 2 | #define __INC_SMARTMATRIX_T3_H 3 | 4 | #ifdef SmartMatrix_h 5 | #include 6 | 7 | FASTLED_NAMESPACE_BEGIN 8 | 9 | extern SmartMatrix *pSmartMatrix; 10 | 11 | // note - dmx simple must be included before FastSPI for this code to be enabled 12 | class CSmartMatrixController : public CLEDController { 13 | SmartMatrix matrix; 14 | 15 | public: 16 | // initialize the LED controller 17 | virtual void init() { 18 | // Initialize 32x32 LED Matrix 19 | matrix.begin(); 20 | matrix.setBrightness(255); 21 | matrix.setColorCorrection(ccNone); 22 | 23 | // Clear screen 24 | clearLeds(0); 25 | matrix.swapBuffers(); 26 | pSmartMatrix = &matrix; 27 | } 28 | 29 | // clear out/zero out the given number of leds. 30 | virtual void clearLeds(int nLeds) { 31 | const rgb24 black = {0,0,0}; 32 | matrix.fillScreen(black); 33 | matrix.swapBuffers(); 34 | } 35 | 36 | // set all the leds on the controller to a given color 37 | virtual void showColor(const struct CRGB & data, int nLeds,CRGB scale) { 38 | PixelController pixels(data, nLeds, scale, getDither()); 39 | rgb24 *md = matrix.backBuffer(); 40 | while(nLeds--) { 41 | md->red = pixels.loadAndScale0(); 42 | md->green = pixels.loadAndScale1(); 43 | md->blue = pixels.loadAndScale2(); 44 | md++; 45 | pixels.stepDithering(); 46 | } 47 | matrix.swapBuffers(); 48 | } 49 | 50 | // note that the uint8_ts will be in the order that you want them sent out to the device. 51 | // nLeds is the number of RGB leds being written to 52 | virtual void show(const struct CRGB *data, int nLeds, CRGB scale) { 53 | PixelController pixels(data, nLeds, scale, getDither()); 54 | #ifdef SMART_MATRIX_CAN_TRIPLE_BUFFER 55 | rgb24 *md = matrix.getRealBackBuffer(); 56 | #else 57 | rgb24 *md = matrix.backBuffer(); 58 | #endif 59 | while(nLeds--) { 60 | md->red = pixels.loadAndScale0(); 61 | md->green = pixels.loadAndScale1(); 62 | md->blue = pixels.loadAndScale2(); 63 | md++; 64 | pixels.advanceData(); 65 | pixels.stepDithering(); 66 | } 67 | matrix.swapBuffers(); 68 | #ifdef SMART_MATRIX_CAN_TRIPLE_BUFFER 69 | matrix.setBackBuffer((rgb24*)data); 70 | #endif 71 | } 72 | 73 | #ifdef SUPPORT_ARGB 74 | // as above, but every 4th uint8_t is assumed to be alpha channel data, and will be skipped 75 | virtual void show(const struct CARGB *data, int nLeds, CRGB scale) = 0; 76 | #endif 77 | }; 78 | 79 | FASTLED_NAMESPACE_END 80 | 81 | #endif 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /Software/Python/bakebit_led_fade.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit LED for LED Fade effect 4 | # http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Red_LED 5 | # http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Green_LED 6 | # 7 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. 8 | # You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 9 | # 10 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 11 | # 12 | 13 | ''' 14 | ## License 15 | 16 | The MIT License (MIT) 17 | 18 | BakeBit for the NanoPi NEO: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 19 | Copyright (C) 2016 FriendlyARM 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in 29 | all copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 37 | THE SOFTWARE. 38 | ''' 39 | 40 | import time 41 | import bakebit 42 | 43 | # Connect the BakeBit LED to digital port D5 44 | # SIG,NC,VCC,GND 45 | led = 5 46 | 47 | # Digital ports that support Pulse Width Modulation (PWM) 48 | # D3, D5, D6 49 | 50 | # Digital ports that do not support PWM 51 | # D2, D4, D7, D8 52 | 53 | bakebit.pinMode(led,"OUTPUT") 54 | time.sleep(1) 55 | i = 0 56 | 57 | while True: 58 | try: 59 | # Reset 60 | if i > 255: 61 | i = 0 62 | 63 | # Current brightness 64 | print (i) 65 | 66 | # Give PWM output to LED 67 | bakebit.analogWrite(led,i) 68 | 69 | # Increment brightness for next iteration 70 | i = i + 20 71 | time.sleep(.5) 72 | 73 | except KeyboardInterrupt: 74 | bakebit.analogWrite(led,0) 75 | break 76 | except IOError: 77 | print ("Error") -------------------------------------------------------------------------------- /Software/Python/bakebit_prj_Ultrasonic_Sensor_with_LED.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit Ultrasonic Ranger (http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Ultrasonic) 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. 6 | # You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 7 | # 8 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 9 | # 10 | ''' 11 | ## License 12 | 13 | The MIT License (MIT) 14 | 15 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 16 | Copyright (C) 2016 FriendlyARM 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy 19 | of this software and associated documentation files (the "Software"), to deal 20 | in the Software without restriction, including without limitation the rights 21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | copies of the Software, and to permit persons to whom the Software is 23 | furnished to do so, subject to the following conditions: 24 | 25 | The above copyright notice and this permission notice shall be included in 26 | all copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 34 | THE SOFTWARE. 35 | ''' 36 | 37 | import bakebit 38 | import time 39 | 40 | # Connect the BakeBit Ultrasonic Ranger to digital port D4 41 | # SIG,NC,VCC,GND 42 | ultrasonic_ranger = 4 43 | 44 | # Connect the BakeBit LED to digital port D3 45 | led = 3 46 | 47 | bakebit.pinMode(led,"OUTPUT") 48 | light = 0 49 | 50 | while True: 51 | try: 52 | # Read distance value from Ultrasonic 53 | distance = bakebit.ultrasonicRead(ultrasonic_ranger) 54 | print(distance) 55 | if distance > 0: 56 | if distance<10: 57 | if light == 0: 58 | print("\ton") 59 | bakebit.digitalWrite(led,1) 60 | light = 1 61 | else: 62 | if light == 1: 63 | print("\toff") 64 | bakebit.digitalWrite(led,0) 65 | light = 0 66 | time.sleep(.2) 67 | 68 | except KeyboardInterrupt: 69 | bakebit.digitalWrite(led,0) 70 | break 71 | 72 | except TypeError: 73 | print ("Error") 74 | except IOError: 75 | print ("Error") 76 | -------------------------------------------------------------------------------- /Software/Python/bakebit_prj_Button_And_Buzzer.py: -------------------------------------------------------------------------------- 1 | # button_buzzer.py 2 | # 3 | # This is an project using the BakeBit Button, Buzzer from the BakeBit starter kit 4 | # 5 | # In this project, the buzzer starts making a sound when the the button is hold 6 | 7 | ''' 8 | The MIT License (MIT) 9 | 10 | BakeBit for the NanoPi NEO: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 11 | Copyright (C) 2016 FriendlyARM 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in 21 | all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | THE SOFTWARE. 30 | ''' 31 | 32 | import time 33 | from bakebit import * 34 | import math 35 | 36 | buzzer_pin = 3 #Port for buzzer 37 | button = 4 #Port for Button 38 | old_button_status = -1 39 | pinMode(buzzer_pin,"OUTPUT") # Assign mode for buzzer as output 40 | pinMode(button,"INPUT") # Assign mode for Button as input 41 | 42 | buzzer_on = False 43 | old_buzzer_on = not buzzer_on 44 | button_pressed = False 45 | 46 | while True: 47 | try: 48 | while True: 49 | button_status = digitalRead(button) #Read the Button status 50 | # print button_status 51 | if old_button_status < 0: 52 | break 53 | 54 | if button_status != old_button_status: 55 | break 56 | 57 | time.sleep(0.2) 58 | old_button_status = button_status 59 | 60 | if button_status == 0: 61 | button_pressed = True 62 | else: 63 | if button_pressed: 64 | buzzer_on = not buzzer_on 65 | button_pressed = False 66 | 67 | if old_buzzer_on != buzzer_on: 68 | old_buzzer_on = buzzer_on 69 | if buzzer_on: 70 | analogWrite(buzzer_pin,127) 71 | print "Buzzing" 72 | else: 73 | analogWrite(buzzer_pin,0) 74 | print "\tOff" 75 | 76 | time.sleep(0.2) 77 | except KeyboardInterrupt: # Stop the buzzer before stopping 78 | digitalWrite(buzzer_pin,0) 79 | break 80 | except (IOError,TypeError) as e: 81 | print("Error") 82 | -------------------------------------------------------------------------------- /Software/Python/bakebit_led_blink.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # BakeBit LED blink Example for the BakeBit LED 4 | # http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Red_LED 5 | # http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Green_LED 6 | # 7 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. 8 | # You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 9 | # 10 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 11 | # 12 | ''' 13 | ## License 14 | 15 | The MIT License (MIT) 16 | 17 | BakeBit for the NanoPi NEO: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 18 | Copyright (C) 2016 FriendlyARM 19 | 20 | Permission is hereby granted, free of charge, to any person obtaining a copy 21 | of this software and associated documentation files (the "Software"), to deal 22 | in the Software without restriction, including without limitation the rights 23 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 24 | copies of the Software, and to permit persons to whom the Software is 25 | furnished to do so, subject to the following conditions: 26 | 27 | The above copyright notice and this permission notice shall be included in 28 | all copies or substantial portions of the Software. 29 | 30 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 36 | THE SOFTWARE. 37 | ''' 38 | 39 | import time 40 | from bakebit import * 41 | 42 | # Connect the BakeBit LED to digital port D3 43 | led = 3 44 | 45 | pinMode(led,"OUTPUT") 46 | time.sleep(1) 47 | 48 | print ("This example will blink a BakeBit LED connected to the BakeBit on the port labeled D3.\nIf you're having trouble seeing the LED blink, be sure to check the LED connection and the port number.\nYou may also try reversing the direction of the LED on the sensor.") 49 | print (" ") 50 | print ("Connect the LED to the port labele D3!" ) 51 | 52 | while True: 53 | try: 54 | #Blink the LED 55 | digitalWrite(led,1) # Send HIGH to switch on LED 56 | print ("LED ON!") 57 | time.sleep(1) 58 | 59 | digitalWrite(led,0) # Send LOW to switch off LED 60 | print ("LED OFF!") 61 | time.sleep(1) 62 | 63 | except KeyboardInterrupt: # Turn LED off before stopping 64 | digitalWrite(led,0) 65 | break 66 | except IOError: # Print "Error" if communication error encountered 67 | print ("Error") 68 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/k20/octows2811_controller.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_OCTOWS2811_CONTROLLER_H 2 | #define __INC_OCTOWS2811_CONTROLLER_H 3 | 4 | #ifdef USE_OCTOWS2811 5 | 6 | // #include "OctoWS2811.h" 7 | 8 | FASTLED_NAMESPACE_BEGIN 9 | 10 | template 11 | class COctoWS2811Controller : public CLEDController { 12 | OctoWS2811 *pocto; 13 | uint8_t *drawbuffer,*framebuffer; 14 | 15 | void _init(int nLeds) { 16 | if(pocto == NULL) { 17 | drawbuffer = (uint8_t*)malloc(nLeds * 8 * 3); 18 | framebuffer = (uint8_t*)malloc(nLeds * 8 * 3); 19 | 20 | // byte ordering is handled in show by the pixel controller 21 | int config = WS2811_RGB; 22 | if(SLOW) { 23 | config |= WS2811_400kHz; 24 | } 25 | 26 | pocto = new OctoWS2811(nLeds, framebuffer, drawbuffer, config); 27 | 28 | pocto->begin(); 29 | } 30 | } 31 | public: 32 | COctoWS2811Controller() { pocto = NULL; } 33 | 34 | 35 | virtual void init() { /* do nothing yet */ } 36 | 37 | virtual void clearLeds(int nLeds) { 38 | _init(nLeds); 39 | showColor(CRGB(0,0,0),nLeds,CRGB(0,0,0)); 40 | } 41 | 42 | virtual void showColor(const struct CRGB & data, int nLeds, CRGB scale) { 43 | _init(nLeds); 44 | // Get our pixel values 45 | PixelController pixels(data, nLeds, scale, getDither()); 46 | uint8_t ball[3][8]; 47 | memset(ball[0],pixels.loadAndScale0(),8); 48 | memset(ball[1],pixels.loadAndScale1(),8); 49 | memset(ball[2],pixels.loadAndScale2(),8); 50 | 51 | uint8_t bout[24]; 52 | transpose8x1_MSB(ball[0],bout); 53 | transpose8x1_MSB(ball[1],bout+8); 54 | transpose8x1_MSB(ball[2],bout+16); 55 | 56 | uint8_t *pdata = drawbuffer; 57 | while(nLeds--) { 58 | memcpy(pdata,bout,24); 59 | pdata += 24; 60 | } 61 | 62 | pocto->show(); 63 | } 64 | 65 | typedef union { 66 | uint8_t bytes[8]; 67 | uint32_t raw[2]; 68 | } Lines; 69 | 70 | virtual void show(const struct CRGB *rgbdata, int nLeds, CRGB scale) { 71 | _init(nLeds); 72 | MultiPixelController<8,0xFF,RGB_ORDER> pixels(rgbdata,nLeds, scale, getDither() ); 73 | 74 | uint8_t *pData = drawbuffer; 75 | while(nLeds--) { 76 | Lines b; 77 | 78 | for(int i = 0; i < 8; i++) { b.bytes[i] = pixels.loadAndScale0(i); } 79 | transpose8x1_MSB(b.bytes,pData); pData += 8; 80 | for(int i = 0; i < 8; i++) { b.bytes[i] = pixels.loadAndScale1(i); } 81 | transpose8x1_MSB(b.bytes,pData); pData += 8; 82 | for(int i = 0; i < 8; i++) { b.bytes[i] = pixels.loadAndScale2(i); } 83 | transpose8x1_MSB(b.bytes,pData); pData += 8; 84 | pixels.stepDithering(); 85 | pixels.advanceData(); 86 | } 87 | 88 | pocto->show(); 89 | } 90 | }; 91 | 92 | FASTLED_NAMESPACE_END 93 | 94 | #endif 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/Encoder.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 2012 Copyright (c) Seeed Technology Inc. 3 | 4 | Author: LG 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | This library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library; if not, write to the Free Software 18 | Foundation, Inc.,51 Franklin St,Fifth Floor, Boston, MA 02110-1301 USA 19 | 20 | */ 21 | #include"Encoder.h" 22 | #include 23 | #include"TimerOne.h" 24 | //TimerOne Timer1; 25 | char ready_msg=0; 26 | //char direct_f=0; 27 | //char direct_b=0; 28 | void timerIsr(); 29 | Encoder::Encoder() 30 | { 31 | //set to input and open the interruput 32 | PCICR=0x04;//enable PCINT[23:16] 33 | PCIFR&=0x011;//Clear PCINT[23:16] flag bit 34 | PCMSK2=0x0C; 35 | } 36 | void Encoder::Timer_init(void) 37 | { 38 | Timer1.initialize(1000); // set a timer of length 100 microseconds 39 | Timer1.attachInterrupt(timerIsr); // attach the service routine here 40 | sei(); 41 | } 42 | void Encoder::Timer_disable(void) 43 | { 44 | Timer1.detachInterrupt(); 45 | } 46 | 47 | ISR(PCINT2_vect) 48 | { 49 | // Serial.println("interrupted1"); 50 | if(ready_msg==1) 51 | { 52 | //Serial.println("interrupted2"); 53 | if(digitalRead(2) > digitalRead(3)) 54 | { 55 | encoder.direct=1;//adjust direction forward 56 | // encoder.direct_b=0;//adjust direction backward 57 | // if(count == 24)count = 24; 58 | // else count ++; 59 | // flag_debug = 1; 60 | encoder.rotate_flag =1; 61 | // counter_100us = 0; 62 | ready_msg=0; 63 | 64 | } 65 | else if(digitalRead(2) to support other boards and timers 8 | * Modified by Mitra Ardron 9 | * Added Sanyo and Mitsubishi controllers 10 | * Modified Sony to spot the repeat codes that some Sony's send 11 | * 12 | * Modifier by 13 | * Interrupt code based on NECIRrcv by Joe Knapp 14 | * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556 15 | * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/ 16 | * 17 | * Modified by 18 | * http://www.seeedstudio.com/ 19 | * For the Grove-IR receiver and Grove-Infrared Emitter 20 | * JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) 21 | */ 22 | 23 | #ifndef _IRSENDREV_H_ 24 | #define _IRSENDREV_H_ 25 | 26 | // len, start_H, start_L, nshort, nlong, data_len, data[data_len].... 27 | #define D_LEN 0 28 | #define D_STARTH 1 29 | #define D_STARTL 2 30 | #define D_SHORT 3 31 | #define D_LONG 4 32 | #define D_DATALEN 5 33 | #define D_DATA 6 34 | 35 | 36 | #define USECPERTICK 50 // microseconds per clock interrupt tick 37 | #define RAWBUF 300 // Length of raw duration buffer 38 | 39 | // Marks tend to be 100us too long, and spaces 100us too short 40 | // when received due to sensor lag. 41 | #define MARK_EXCESS 100 42 | 43 | #define __DEBUG 0 44 | 45 | // Results returned from the decoder 46 | class decode_results { 47 | 48 | public: 49 | volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks 50 | int rawlen; // Number of records in rawbuf. 51 | }; 52 | 53 | // main class for receiving IR 54 | class IRSendRev 55 | { 56 | private: 57 | decode_results results; 58 | //**************************rev********************************** 59 | 60 | private: 61 | int decode(decode_results *results); 62 | void enableIRIn(); 63 | 64 | public: 65 | 66 | void Init(int revPin); // init 67 | void Init(); 68 | unsigned char Recv(unsigned char *revData); // 69 | unsigned char IsDta(); // if IR get data 70 | void Clear(); // clear IR data 71 | 72 | //**************************send********************************* 73 | private: 74 | 75 | void sendRaw(unsigned int buf[], int len, int hz); 76 | 77 | // private: 78 | 79 | void mark(int usec); 80 | void space(int usec); 81 | void enableIROut(int khz); 82 | 83 | public: 84 | 85 | void Send(unsigned char *idata, unsigned char ifreq); 86 | 87 | }; 88 | 89 | extern IRSendRev IR; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/color.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_COLOR_H 2 | #define __INC_COLOR_H 3 | 4 | FASTLED_NAMESPACE_BEGIN 5 | 6 | ///@file color.h 7 | /// contains definitions for color correction and temperature 8 | ///@defgroup ColorEnums Color correction/temperature 9 | /// definitions for color correction and light temperatures 10 | ///@{ 11 | typedef enum { 12 | // Color correction starting points 13 | 14 | /// typical values for SMD5050 LEDs 15 | ///@{ 16 | TypicalSMD5050=0xFFB0F0 /* 255, 176, 240 */, 17 | TypicalLEDStrip=0xFFB0F0 /* 255, 176, 240 */, 18 | ///@} 19 | 20 | /// typical values for 8mm "pixels on a string" 21 | /// also for many through-hole 'T' package LEDs 22 | ///@{ 23 | Typical8mmPixel=0xFFE08C /* 255, 224, 140 */, 24 | TypicalPixelString=0xFFE08C /* 255, 224, 140 */, 25 | ///@} 26 | 27 | /// uncorrected color 28 | UncorrectedColor=0xFFFFFF 29 | 30 | } LEDColorCorrection; 31 | 32 | 33 | typedef enum { 34 | /// @name Black-body radiation light sources 35 | /// Black-body radiation light sources emit a (relatively) continuous 36 | /// spectrum, and can be described as having a Kelvin 'temperature' 37 | ///@{ 38 | /// 1900 Kelvin 39 | Candle=0xFF9329 /* 1900 K, 255, 147, 41 */, 40 | /// 2600 Kelvin 41 | Tungsten40W=0xFFC58F /* 2600 K, 255, 197, 143 */, 42 | /// 2850 Kelvin 43 | Tungsten100W=0xFFD6AA /* 2850 K, 255, 214, 170 */, 44 | /// 3200 Kelvin 45 | Halogen=0xFFF1E0 /* 3200 K, 255, 241, 224 */, 46 | /// 5200 Kelvin 47 | CarbonArc=0xFFFAF4 /* 5200 K, 255, 250, 244 */, 48 | /// 5400 Kelvin 49 | HighNoonSun=0xFFFFFB /* 5400 K, 255, 255, 251 */, 50 | /// 6000 Kelvin 51 | DirectSunlight=0xFFFFFF /* 6000 K, 255, 255, 255 */, 52 | /// 7000 Kelvin 53 | OvercastSky=0xC9E2FF /* 7000 K, 201, 226, 255 */, 54 | /// 20000 Kelvin 55 | ClearBlueSky=0x409CFF /* 20000 K, 64, 156, 255 */, 56 | ///@} 57 | 58 | /// @name Gaseous light sources 59 | /// Gaseous light sources emit discrete spectral bands, and while we can 60 | /// approximate their aggregate hue with RGB values, they don't actually 61 | /// have a proper Kelvin temperature. 62 | ///@{ 63 | WarmFluorescent=0xFFF4E5 /* 0 K, 255, 244, 229 */, 64 | StandardFluorescent=0xF4FFFA /* 0 K, 244, 255, 250 */, 65 | CoolWhiteFluorescent=0xD4EBFF /* 0 K, 212, 235, 255 */, 66 | FullSpectrumFluorescent=0xFFF4F2 /* 0 K, 255, 244, 242 */, 67 | GrowLightFluorescent=0xFFEFF7 /* 0 K, 255, 239, 247 */, 68 | BlackLightFluorescent=0xA700FF /* 0 K, 167, 0, 255 */, 69 | MercuryVapor=0xD8F7FF /* 0 K, 216, 247, 255 */, 70 | SodiumVapor=0xFFD1B2 /* 0 K, 255, 209, 178 */, 71 | MetalHalide=0xF2FCFF /* 0 K, 242, 252, 255 */, 72 | HighPressureSodium=0xFFB74C /* 0 K, 255, 183, 76 */, 73 | ///@} 74 | 75 | /// Uncorrected temperature 0xFFFFFF 76 | UncorrectedTemperature=0xFFFFFF 77 | } ColorTemperature; 78 | 79 | FASTLED_NAMESPACE_END 80 | 81 | ///@} 82 | #endif 83 | -------------------------------------------------------------------------------- /Software/Python/bakebit_light_sensor.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit Light Sensor and the LED together to turn the LED On and OFF if the background light is greater than a threshold. 4 | # Modules: 5 | # http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Light_Sensor 6 | # http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Red_LED 7 | # 8 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. 9 | # You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 10 | # 11 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 12 | # 13 | ''' 14 | ## License 15 | 16 | The MIT License (MIT) 17 | 18 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 19 | Copyright (C) 2016 FriendlyARM 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in 29 | all copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 37 | THE SOFTWARE. 38 | ''' 39 | 40 | import time 41 | import bakebit 42 | 43 | # Connect the BakeBit Light Sensor to analog port A0 44 | # SIG,NC,VCC,GND 45 | light_sensor = 0 46 | 47 | # Connect the LED to digital port D4 48 | # SIG,NC,VCC,GND 49 | led = 4 50 | 51 | # Turn on LED once sensor exceeds threshold resistance 52 | threshold = 10 53 | 54 | bakebit.pinMode(light_sensor,"INPUT") 55 | bakebit.pinMode(led,"OUTPUT") 56 | 57 | while True: 58 | try: 59 | # Get sensor value 60 | sensor_value = bakebit.analogRead(light_sensor) 61 | 62 | # Calculate resistance of sensor in K 63 | resistance = (float)(1023 - sensor_value) * 10 / sensor_value 64 | 65 | if resistance > threshold: 66 | # Send HIGH to switch on LED 67 | bakebit.digitalWrite(led,1) 68 | else: 69 | # Send LOW to switch off LED 70 | bakebit.digitalWrite(led,0) 71 | 72 | print("sensor_value = %d resistance =%.2f" %(sensor_value, resistance)) 73 | time.sleep(.5) 74 | 75 | except IOError: 76 | print ("Error") 77 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/lib8tion/random8.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_LIB8TION_RANDOM_H 2 | #define __INC_LIB8TION_RANDOM_H 3 | ///@ingroup lib8tion 4 | 5 | ///@defgroup Random Fast random number generators 6 | /// Fast 8- and 16- bit unsigned random numbers. 7 | /// Significantly faster than Arduino random(), but 8 | /// also somewhat less random. You can add entropy. 9 | ///@{ 10 | 11 | // X(n+1) = (2053 * X(n)) + 13849) 12 | #define FASTLED_RAND16_2053 ((uint16_t)(2053)) 13 | #define FASTLED_RAND16_13849 ((uint16_t)(13849)) 14 | 15 | /// random number seed 16 | extern uint16_t rand16seed;// = RAND16_SEED; 17 | 18 | /// Generate an 8-bit random number 19 | LIB8STATIC uint8_t random8() 20 | { 21 | rand16seed = (rand16seed * FASTLED_RAND16_2053) + FASTLED_RAND16_13849; 22 | // return the sum of the high and low bytes, for better 23 | // mixing and non-sequential correlation 24 | return (uint8_t)(((uint8_t)(rand16seed & 0xFF)) + 25 | ((uint8_t)(rand16seed >> 8))); 26 | } 27 | 28 | /// Generate a 16 bit random number 29 | LIB8STATIC uint16_t random16() 30 | { 31 | rand16seed = (rand16seed * FASTLED_RAND16_2053) + FASTLED_RAND16_13849; 32 | return rand16seed; 33 | } 34 | 35 | /// Generate an 8-bit random number between 0 and lim 36 | /// @param lim the upper bound for the result 37 | LIB8STATIC uint8_t random8(uint8_t lim) 38 | { 39 | uint8_t r = random8(); 40 | r = scale8( r, lim); 41 | return r; 42 | } 43 | 44 | /// Generate an 8-bit random number in the given range 45 | /// @param min the lower bound for the random number 46 | /// @param lim the upper bound for the random number 47 | LIB8STATIC uint8_t random8(uint8_t min, uint8_t lim) 48 | { 49 | uint8_t delta = lim - min; 50 | uint8_t r = random8(delta) + min; 51 | return r; 52 | } 53 | 54 | /// Generate an 16-bit random number between 0 and lim 55 | /// @param lim the upper bound for the result 56 | LIB8STATIC uint16_t random16( uint16_t lim) 57 | { 58 | uint16_t r = random16(); 59 | uint32_t p = (uint32_t)lim * (uint32_t)r; 60 | r = p >> 16; 61 | return r; 62 | } 63 | 64 | /// Generate an 16-bit random number in the given range 65 | /// @param min the lower bound for the random number 66 | /// @param lim the upper bound for the random number 67 | LIB8STATIC uint16_t random16( uint16_t min, uint16_t lim) 68 | { 69 | uint16_t delta = lim - min; 70 | uint16_t r = random16( delta) + min; 71 | return r; 72 | } 73 | 74 | /// Set the 16-bit seed used for the random number generator 75 | LIB8STATIC void random16_set_seed( uint16_t seed) 76 | { 77 | rand16seed = seed; 78 | } 79 | 80 | /// Get the current seed value for the random number generator 81 | LIB8STATIC uint16_t random16_get_seed() 82 | { 83 | return rand16seed; 84 | } 85 | 86 | /// Add entropy into the random number generator 87 | LIB8STATIC void random16_add_entropy( uint16_t entropy) 88 | { 89 | rand16seed += entropy; 90 | } 91 | 92 | ///@} 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/d21/clockless_arm_d21.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_ARM_D21 2 | #define __INC_CLOCKLESS_ARM_D21 3 | 4 | #include "platforms/arm/common/m0clockless.h" 5 | FASTLED_NAMESPACE_BEGIN 6 | #define FASTLED_HAS_CLOCKLESS 1 7 | 8 | template 9 | class ClocklessController : public CLEDController { 10 | typedef typename FastPinBB::port_ptr_t data_ptr_t; 11 | typedef typename FastPinBB::port_t data_t; 12 | 13 | data_t mPinMask; 14 | data_ptr_t mPort; 15 | CMinWait mWait; 16 | public: 17 | virtual void init() { 18 | FastPinBB::setOutput(); 19 | mPinMask = FastPinBB::mask(); 20 | mPort = FastPinBB::port(); 21 | } 22 | 23 | virtual uint16_t getMaxRefreshRate() const { return 400; } 24 | 25 | virtual void clearLeds(int nLeds) { 26 | showColor(CRGB(0, 0, 0), nLeds, 0); 27 | } 28 | 29 | // set all the leds on the controller to a given color 30 | virtual void showColor(const struct CRGB & rgbdata, int nLeds, CRGB scale) { 31 | PixelController pixels(rgbdata, nLeds, scale, getDither()); 32 | mWait.wait(); 33 | cli(); 34 | 35 | showRGBInternal(pixels); 36 | 37 | sei(); 38 | mWait.mark(); 39 | } 40 | 41 | virtual void show(const struct CRGB *rgbdata, int nLeds, CRGB scale) { 42 | PixelController pixels(rgbdata, nLeds, scale, getDither()); 43 | mWait.wait(); 44 | cli(); 45 | 46 | showRGBInternal(pixels); 47 | 48 | sei(); 49 | mWait.mark(); 50 | } 51 | 52 | #ifdef SUPPORT_ARGB 53 | virtual void show(const struct CARGB *rgbdata, int nLeds, CRGB scale) { 54 | PixelController pixels(rgbdata, nLeds, scale, getDither()); 55 | mWait.wait(); 56 | cli(); 57 | showRGBInternal(pixels); 58 | sei(); 59 | mWait.mark(); 60 | } 61 | #endif 62 | 63 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 64 | // gcc will use register Y for the this pointer. 65 | static uint32_t showRGBInternal(PixelController & pixels) { 66 | struct M0ClocklessData data; 67 | data.d[0] = pixels.d[0]; 68 | data.d[1] = pixels.d[1]; 69 | data.d[2] = pixels.d[2]; 70 | data.s[0] = pixels.mScale[0]; 71 | data.s[1] = pixels.mScale[1]; 72 | data.s[2] = pixels.mScale[2]; 73 | data.e[0] = pixels.e[0]; 74 | data.e[1] = pixels.e[1]; 75 | data.e[2] = pixels.e[2]; 76 | data.adj = pixels.mAdvance; 77 | 78 | typename FastPin::port_ptr_t portBase = FastPin::port(); 79 | showLedData<8,4,T1,T2,T3,RGB_ORDER, WAIT_TIME>(portBase, FastPin::mask(), pixels.mData, pixels.mLen, &data); 80 | return 0; // 0x00FFFFFF - _VAL; 81 | } 82 | 83 | 84 | }; 85 | 86 | FASTLED_NAMESPACE_END 87 | 88 | 89 | #endif // __INC_CLOCKLESS_ARM_D21 90 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/kl26/clockless_arm_kl26.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_ARM_KL26 2 | #define __INC_CLOCKLESS_ARM_KL26 3 | 4 | #include "platforms/arm/common/m0clockless.h" 5 | FASTLED_NAMESPACE_BEGIN 6 | #define FASTLED_HAS_CLOCKLESS 1 7 | 8 | template 9 | class ClocklessController : public CLEDController { 10 | typedef typename FastPinBB::port_ptr_t data_ptr_t; 11 | typedef typename FastPinBB::port_t data_t; 12 | 13 | data_t mPinMask; 14 | data_ptr_t mPort; 15 | CMinWait mWait; 16 | public: 17 | virtual void init() { 18 | FastPinBB::setOutput(); 19 | mPinMask = FastPinBB::mask(); 20 | mPort = FastPinBB::port(); 21 | } 22 | 23 | virtual uint16_t getMaxRefreshRate() const { return 400; } 24 | 25 | virtual void clearLeds(int nLeds) { 26 | showColor(CRGB(0, 0, 0), nLeds, 0); 27 | } 28 | 29 | // set all the leds on the controller to a given color 30 | virtual void showColor(const struct CRGB & rgbdata, int nLeds, CRGB scale) { 31 | PixelController pixels(rgbdata, nLeds, scale, getDither()); 32 | mWait.wait(); 33 | cli(); 34 | 35 | showRGBInternal(pixels); 36 | 37 | sei(); 38 | mWait.mark(); 39 | } 40 | 41 | virtual void show(const struct CRGB *rgbdata, int nLeds, CRGB scale) { 42 | PixelController pixels(rgbdata, nLeds, scale, getDither()); 43 | mWait.wait(); 44 | cli(); 45 | 46 | showRGBInternal(pixels); 47 | 48 | sei(); 49 | mWait.mark(); 50 | } 51 | 52 | #ifdef SUPPORT_ARGB 53 | virtual void show(const struct CARGB *rgbdata, int nLeds, CRGB scale) { 54 | PixelController pixels(rgbdata, nLeds, scale, getDither()); 55 | mWait.wait(); 56 | cli(); 57 | showRGBInternal(pixels); 58 | sei(); 59 | mWait.mark(); 60 | } 61 | #endif 62 | 63 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 64 | // gcc will use register Y for the this pointer. 65 | static uint32_t showRGBInternal(PixelController & pixels) { 66 | struct M0ClocklessData data; 67 | data.d[0] = pixels.d[0]; 68 | data.d[1] = pixels.d[1]; 69 | data.d[2] = pixels.d[2]; 70 | data.s[0] = pixels.mScale[0]; 71 | data.s[1] = pixels.mScale[1]; 72 | data.s[2] = pixels.mScale[2]; 73 | data.e[0] = pixels.e[0]; 74 | data.e[1] = pixels.e[1]; 75 | data.e[2] = pixels.e[2]; 76 | data.adj = pixels.mAdvance; 77 | 78 | typename FastPin::port_ptr_t portBase = FastPin::port(); 79 | showLedData<4,8,T1,T2,T3,RGB_ORDER, WAIT_TIME>(portBase, FastPin::mask(), pixels.mData, pixels.mLen, &data); 80 | return 0; // 0x00FFFFFF - _VAL; 81 | } 82 | 83 | 84 | }; 85 | 86 | FASTLED_NAMESPACE_END 87 | 88 | 89 | #endif // __INC_CLOCKLESS_ARM_D21 90 | -------------------------------------------------------------------------------- /Software/Python/bakebit_prj_Servo_And_RotaryAngleSensor.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit Servo (http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_LED_Bar) 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. You can learn more about BakeBit here: http://wiki.friendlyarm.com/bakebit 6 | # 7 | # 8 | ''' 9 | ## License 10 | 11 | The MIT License (MIT) 12 | 13 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 14 | Copyright (C) 2016 FriendlyARM 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining a copy 17 | of this software and associated documentation files (the "Software"), to deal 18 | in the Software without restriction, including without limitation the rights 19 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20 | copies of the Software, and to permit persons to whom the Software is 21 | furnished to do so, subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be included in 24 | all copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 32 | THE SOFTWARE. 33 | ''' 34 | 35 | import time 36 | import bakebit 37 | import random 38 | 39 | # Connect the servo to digital port D5 40 | # SIG,NC,VCC,GND 41 | servo = 5 42 | 43 | # Connect the BakeBit Rotary Angle Sensor to analog port A0 44 | # SIG,NC,VCC,GND 45 | potentiometer = 0 46 | 47 | # Reference voltage of ADC is 5v 48 | adc_ref = 5 49 | 50 | # Vcc of the bakebit interface is normally 5v 51 | bakebit_vcc = 5 52 | 53 | # Full value of the rotary angle is 180 degrees, as per it's specs (0 to 180) 54 | full_angle = 180 55 | old_degrees = -1 56 | 57 | bakebit.pinMode(potentiometer,"INPUT") 58 | bakebit.bakeBitServo_Attach(servo) 59 | 60 | 61 | while True: 62 | try: 63 | # Read sensor value from potentiometer 64 | sensor_value = bakebit.analogRead(potentiometer) 65 | 66 | # Calculate voltage 67 | voltage = round((float)(sensor_value) * adc_ref / 1023, 2) 68 | 69 | # Calculate rotation in degrees (0 to 180) 70 | degrees = int((voltage * full_angle) / bakebit_vcc) 71 | 72 | if degrees != old_degrees: 73 | print("sensor_value = %d voltage = %.2f degrees = %d" % (sensor_value, voltage, degrees)) 74 | bakebit.bakeBitServo_Write(servo, degrees) 75 | 76 | old_degrees = degrees 77 | 78 | except KeyboardInterrupt: 79 | bakebit.bakeBitServo_Detach(servo) 80 | break 81 | except IOError: 82 | print ("Error") 83 | 84 | 85 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set github default language setting. 3 | ############################################################################### 4 | Firmware/* linguist-vendored 5 | Hardware/* linguist-vendored 6 | *.c linguist-language=Python 7 | *.h linguist-language=Python 8 | *.py linguist-language=Python 9 | 10 | ############################################################################### 11 | # Set default behavior to automatically normalize line endings. 12 | ############################################################################### 13 | * text=auto 14 | 15 | ############################################################################### 16 | # Set default behavior for command prompt diff. 17 | # 18 | # This is need for earlier builds of msysgit that does not have it on by 19 | # default for csharp files. 20 | # Note: This is only used by command line 21 | ############################################################################### 22 | #*.cs diff=csharp 23 | 24 | ############################################################################### 25 | # Set the merge driver for project and solution files 26 | # 27 | # Merging from the command prompt will add diff markers to the files if there 28 | # are conflicts (Merging from VS is not affected by the settings below, in VS 29 | # the diff markers are never inserted). Diff markers may cause the following 30 | # file extensions to fail to load in VS. An alternative would be to treat 31 | # these files as binary and thus will always conflict and require user 32 | # intervention with every merge. To do so, just uncomment the entries below 33 | ############################################################################### 34 | #*.sln merge=binary 35 | #*.csproj merge=binary 36 | #*.vbproj merge=binary 37 | #*.vcxproj merge=binary 38 | #*.vcproj merge=binary 39 | #*.dbproj merge=binary 40 | #*.fsproj merge=binary 41 | #*.lsproj merge=binary 42 | #*.wixproj merge=binary 43 | #*.modelproj merge=binary 44 | #*.sqlproj merge=binary 45 | #*.wwaproj merge=binary 46 | 47 | ############################################################################### 48 | # behavior for image files 49 | # 50 | # image files are treated as binary by default. 51 | ############################################################################### 52 | #*.jpg binary 53 | #*.png binary 54 | #*.gif binary 55 | 56 | ############################################################################### 57 | # diff behavior for common document formats 58 | # 59 | # Convert binary document formats to text before diffing them. This feature 60 | # is only available from the command line. Turn it on by uncommenting the 61 | # entries below. 62 | ############################################################################### 63 | #*.doc diff=astextplain 64 | #*.DOC diff=astextplain 65 | #*.docx diff=astextplain 66 | #*.DOCX diff=astextplain 67 | #*.dot diff=astextplain 68 | #*.DOT diff=astextplain 69 | #*.pdf diff=astextplain 70 | #*.PDF diff=astextplain 71 | #*.rtf diff=astextplain 72 | #*.RTF diff=astextplain 73 | -------------------------------------------------------------------------------- /Software/Python/bakebit_rotary_angle_sensor.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit Rotary Angle Sensor (Potentiometer) and the BakeBit LED to create LED sweep 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 6 | # 7 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 8 | # 9 | ''' 10 | ## License 11 | 12 | The MIT License (MIT) 13 | 14 | BakeBit for the NanoPi NEO: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 15 | Copyright (C) 2015 FriendlyARM 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy 18 | of this software and associated documentation files (the "Software"), to deal 19 | in the Software without restriction, including without limitation the rights 20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 | copies of the Software, and to permit persons to whom the Software is 22 | furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in 25 | all copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 33 | THE SOFTWARE. 34 | ''' 35 | 36 | 37 | import time 38 | import bakebit 39 | 40 | # Connect the BakeBit Rotary Angle Sensor to analog port A0 41 | # SIG,NC,VCC,GND 42 | potentiometer = 0 43 | 44 | # Connect the LED to digital port D5 45 | # SIG,NC,VCC,GND 46 | led = 5 47 | 48 | bakebit.pinMode(potentiometer,"INPUT") 49 | bakebit.pinMode(led,"OUTPUT") 50 | time.sleep(1) 51 | 52 | # Reference voltage of ADC is 5v 53 | adc_ref = 5 54 | 55 | # Vcc of the BakeBit interface is normally 5v 56 | bakebit_vcc = 5 57 | 58 | # Full value of the rotary angle is 300 degrees, as per it's specs (0 to 300) 59 | full_angle = 300 60 | 61 | while True: 62 | try: 63 | # Read sensor value from potentiometer 64 | sensor_value = bakebit.analogRead(potentiometer) 65 | 66 | # Calculate voltage 67 | voltage = round((float)(sensor_value) * adc_ref / 1023, 2) 68 | 69 | # Calculate rotation in degrees (0 to 300) 70 | degrees = round((voltage * full_angle) / bakebit_vcc, 2) 71 | 72 | # Calculate LED brightess (0 to 255) from degrees (0 to 300) 73 | brightness = int(degrees / full_angle * 255) 74 | 75 | # Give PWM output to LED 76 | bakebit.analogWrite(led,brightness) 77 | 78 | print("sensor_value = %d voltage = %.2f degrees = %.1f brightness = %d" %(sensor_value, voltage, degrees, brightness)) 79 | except KeyboardInterrupt: 80 | bakebit.analogWrite(led,0) 81 | break 82 | except IOError: 83 | print ("Error") 84 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/TimerOne.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Interrupt and PWM utilities for 16 bit Timer1 on ATmega168/328 3 | * Original code by Jesse Tane for http://labs.ideo.com August 2008 4 | * Modified March 2009 by Jérôme Despatis and Jesse Tane for ATmega328 support 5 | * Modified June 2009 by Michael Polli and Jesse Tane to fix a bug in setPeriod() which caused the timer to stop 6 | * Modified June 2011 by Lex Talionis to add a function to read the timer 7 | * Modified Oct 2011 by Andrew Richards to avoid certain problems: 8 | * - Add (long) assignments and casts to TimerOne::read() to ensure calculations involving tmp, ICR1 and TCNT1 aren't truncated 9 | * - Ensure 16 bit registers accesses are atomic - run with interrupts disabled when accessing 10 | * - Remove global enable of interrupts (sei())- could be running within an interrupt routine) 11 | * - Disable interrupts whilst TCTN1 == 0. Datasheet vague on this, but experiment shows that overflow interrupt 12 | * flag gets set whilst TCNT1 == 0, resulting in a phantom interrupt. Could just set to 1, but gets inaccurate 13 | * at very short durations 14 | * - startBottom() added to start counter at 0 and handle all interrupt enabling. 15 | * - start() amended to enable interrupts 16 | * - restart() amended to point at startBottom() 17 | * Modiied 7:26 PM Sunday, October 09, 2011 by Lex Talionis 18 | * - renamed start() to resume() to reflect it's actual role 19 | * - renamed startBottom() to start(). This breaks some old code that expects start to continue counting where it left off 20 | * 21 | * This program is free software: you can redistribute it and/or modify 22 | * it under the terms of the GNU General Public License as published by 23 | * the Free Software Foundation, either version 3 of the License, or 24 | * (at your option) any later version. 25 | * 26 | * This program is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 | * GNU General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU General Public License 32 | * along with this program. If not, see . 33 | * 34 | * See Google Code project http://code.google.com/p/arduino-timerone/ for latest 35 | */ 36 | #ifndef TIMERONE_h 37 | #define TIMERONE_h 38 | 39 | #include 40 | #include 41 | 42 | #define RESOLUTION 65536 // Timer1 is 16 bit 43 | 44 | class TimerOne 45 | { 46 | public: 47 | 48 | // properties 49 | unsigned int pwmPeriod; 50 | unsigned char clockSelectBits; 51 | char oldSREG; // To hold Status Register while ints disabled 52 | 53 | // methods 54 | void initialize(long microseconds=1000000); 55 | void start(); 56 | void stop(); 57 | void restart(); 58 | void resume(); 59 | unsigned long read(); 60 | void pwm(char pin, int duty, long microseconds=-1); 61 | void disablePwm(char pin); 62 | void attachInterrupt(void (*isr)(), long microseconds=-1); 63 | void detachInterrupt(); 64 | void setPeriod(long microseconds); 65 | void setPwmDuty(char pin, int duty); 66 | void (*isrCallback)(); 67 | }; 68 | 69 | extern TimerOne Timer1; 70 | #endif -------------------------------------------------------------------------------- /Software/Python/bakebit_ledbar.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit LED Bar (http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_LED_Bar) 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. 6 | # You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 7 | # 8 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 9 | # 10 | ''' 11 | ## License 12 | 13 | The MIT License (MIT) 14 | 15 | BakeBit for the NanoPi NEO: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 16 | Copyright (C) 2016 FriendlyARM 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy 19 | of this software and associated documentation files (the "Software"), to deal 20 | in the Software without restriction, including without limitation the rights 21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | copies of the Software, and to permit persons to whom the Software is 23 | furnished to do so, subject to the following conditions: 24 | 25 | The above copyright notice and this permission notice shall be included in 26 | all copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 34 | THE SOFTWARE. 35 | ''' 36 | 37 | import time 38 | import bakebit 39 | import random 40 | 41 | # Connect the BakeBit LED Bar to digital port D3 42 | # DI,DCKI,VCC,GND 43 | ledbar = 3 44 | 45 | bakebit.pinMode(ledbar,"OUTPUT") 46 | time.sleep(.2) 47 | i = 0 48 | old_color = 0 49 | 50 | bakebit.bakeBitLedBar_Init(ledbar, 0, 5) 51 | time.sleep(.5) 52 | 53 | while True: 54 | try: 55 | for i in range(0,5): 56 | color16bit = bakebit.Green 57 | if i >= 1: 58 | color16bit = color16bit | (bakebit.Green << 3) 59 | if i >= 2: 60 | color16bit = color16bit | (bakebit.Green << 6) 61 | if i >= 3: 62 | color16bit = color16bit | (bakebit.Yellow << 9) 63 | if i >= 4: 64 | color16bit = 0 65 | color16bit = color16bit | bakebit.Red 66 | color16bit = color16bit | (bakebit.Red << 3) 67 | color16bit = color16bit | (bakebit.Red << 6) 68 | color16bit = color16bit | (bakebit.Red << 9) 69 | color16bit = color16bit | (bakebit.Red << 12) 70 | if color16bit != old_color: 71 | old_color = color16bit 72 | lowBits = color16bit & 255 73 | highBits = (color16bit & (255 << 8)) >> 8 74 | bakebit.bakeBitLedBar_Show(ledbar, highBits, lowBits) 75 | time.sleep(1) 76 | except KeyboardInterrupt: 77 | bakebit.bakeBitLedBar_Release(ledbar) 78 | time.sleep(.5) 79 | break 80 | except IOError: 81 | print ("Error") 82 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/Pintest/Pintest.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | const char *getPort(void *portPtr) { 5 | #ifdef PORTA 6 | if(portPtr == (void*)&PORTA) { return "PORTA"; } 7 | #endif 8 | #ifdef PORTB 9 | if(portPtr == (void*)&PORTB) { return "PORTB"; } 10 | #endif 11 | #ifdef PORTC 12 | if(portPtr == (void*)&PORTC) { return "PORTC"; } 13 | #endif 14 | #ifdef PORTD 15 | if(portPtr == (void*)&PORTD) { return "PORTD"; } 16 | #endif 17 | #ifdef PORTE 18 | if(portPtr == (void*)&PORTE) { return "PORTE"; } 19 | #endif 20 | #ifdef PORTF 21 | if(portPtr == (void*)&PORTF) { return "PORTF"; } 22 | #endif 23 | #ifdef PORTG 24 | if(portPtr == (void*)&PORTG) { return "PORTG"; } 25 | #endif 26 | #ifdef PORTH 27 | if(portPtr == (void*)&PORTH) { return "PORTH"; } 28 | #endif 29 | #ifdef PORTI 30 | if(portPtr == (void*)&PORTI) { return "PORTI"; } 31 | #endif 32 | #ifdef PORTJ 33 | if(portPtr == (void*)&PORTJ) { return "PORTJ"; } 34 | #endif 35 | #ifdef PORTK 36 | if(portPtr == (void*)&PORTK) { return "PORTK"; } 37 | #endif 38 | #ifdef PORTL 39 | if(portPtr == (void*)&PORTL) { return "PORTL"; } 40 | #endif 41 | #ifdef GPIO_A_PDOR 42 | if(portPtr == (void*)&GPIO_A_PDOR) { return "GPIO_A_PDOR"; } 43 | #endif 44 | #ifdef GPIO_B_PDOR 45 | if(portPtr == (void*)&GPIO_B_PDOR) { return "GPIO_B_PDOR"; } 46 | #endif 47 | #ifdef GPIO_C_PDOR 48 | if(portPtr == (void*)&GPIO_C_PDOR) { return "GPIO_C_PDOR"; } 49 | #endif 50 | #ifdef GPIO_D_PDOR 51 | if(portPtr == (void*)&GPIO_D_PDOR) { return "GPIO_D_PDOR"; } 52 | #endif 53 | #ifdef GPIO_E_PDOR 54 | if(portPtr == (void*)&GPIO_E_PDOR) { return "GPIO_E_PDOR"; } 55 | #endif 56 | #ifdef REG_PIO_A_ODSR 57 | if(portPtr == (void*)®_PIO_A_ODSR) { return "REG_PIO_A_ODSR"; } 58 | #endif 59 | #ifdef REG_PIO_B_ODSR 60 | if(portPtr == (void*)®_PIO_B_ODSR) { return "REG_PIO_B_ODSR"; } 61 | #endif 62 | #ifdef REG_PIO_C_ODSR 63 | if(portPtr == (void*)®_PIO_C_ODSR) { return "REG_PIO_C_ODSR"; } 64 | #endif 65 | #ifdef REG_PIO_D_ODSR 66 | if(portPtr == (void*)®_PIO_D_ODSR) { return "REG_PIO_D_ODSR"; } 67 | #endif 68 | return "unknown"; 69 | } 70 | 71 | template void CheckPin() 72 | { 73 | CheckPin(); 74 | 75 | RwReg *systemThinksPortIs = portOutputRegister(digitalPinToPort(PIN)); 76 | RwReg systemThinksMaskIs = digitalPinToBitMask(PIN); 77 | 78 | Serial.print("Pin "); Serial.print(PIN); Serial.print(": Port "); 79 | 80 | if(systemThinksPortIs == FastPin::port()) { 81 | Serial.print("valid & mask "); 82 | } else { 83 | Serial.print("invalid, is "); Serial.print(getPort((void*)FastPin::port())); Serial.print(" should be "); 84 | Serial.print(getPort((void*)systemThinksPortIs)); 85 | Serial.print(" & mask "); 86 | } 87 | 88 | if(systemThinksMaskIs == FastPin::mask()) { 89 | Serial.println("valid."); 90 | } else { 91 | Serial.print("invalid, is "); Serial.print(FastPin::mask()); Serial.print(" should be "); Serial.println(systemThinksMaskIs); 92 | } 93 | } 94 | 95 | template<> void CheckPin<-1> () {} 96 | 97 | void setup() { 98 | Serial.begin(38400); 99 | Serial.println("resetting!"); 100 | } 101 | 102 | void loop() { 103 | CheckPin(); 104 | delay(10000); 105 | } -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/RGBCalibrate/RGBCalibrate.ino: -------------------------------------------------------------------------------- 1 | #include "FastLED.h" 2 | 3 | 4 | //////////////////////////////////////////////////////////////////////////////////////////////////// 5 | // 6 | // RGB Calibration code 7 | // 8 | // Use this sketch to determine what the RGB ordering for your chipset should be. Steps for setting up to use: 9 | 10 | // * Uncomment the line in setup that corresponds to the LED chipset that you are using. (Note that they 11 | // all explicitly specify the RGB order as RGB) 12 | // * Define DATA_PIN to the pin that data is connected to. 13 | // * (Optional) if using software SPI for chipsets that are SPI based, define CLOCK_PIN to the clock pin 14 | // * Compile/upload/run the sketch 15 | 16 | // You should see six leds on. If the RGB ordering is correct, you should see 1 red led, 2 green 17 | // leds, and 3 blue leds. If you see different colors, the count of each color tells you what the 18 | // position for that color in the rgb orering should be. So, for example, if you see 1 Blue, and 2 19 | // Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green). 20 | 21 | // You can then test this ordering by setting the RGB ordering in the addLeds line below to the new ordering 22 | // and it should come out correctly, 1 red, 2 green, and 3 blue. 23 | // 24 | ////////////////////////////////////////////////// 25 | 26 | #define NUM_LEDS 6 27 | 28 | // Data pin that led data will be written out over 29 | #define DATA_PIN 6 30 | // Clock pin only needed for SPI based chipsets when not using hardware SPI 31 | //#define CLOCK_PIN 8 32 | 33 | CRGB leds[NUM_LEDS]; 34 | 35 | void setup() { 36 | // sanity check delay - allows reprogramming if accidently blowing power w/leds 37 | delay(2000); 38 | 39 | // Uncomment one of the following lines for your leds arrangement. 40 | // FastLED.addLeds(leds, NUM_LEDS); 41 | // FastLED.addLeds(leds, NUM_LEDS); 42 | // FastLED.addLeds(leds, NUM_LEDS); 43 | // FastLED.addLeds(leds, NUM_LEDS); 44 | // FastLED.addLeds(leds, NUM_LEDS); 45 | // FastLED.addLeds(leds, NUM_LEDS); 46 | // FastLED.setBrightness(CRGB(255,255,255)); 47 | // FastLED.addLeds(leds, NUM_LEDS); 48 | // FastLED.addLeds(leds, NUM_LEDS); 49 | // FastLED.addLeds(leds, NUM_LEDS); 50 | // FastLED.addLeds(leds, NUM_LEDS); 51 | 52 | // FastLED.addLeds(leds, NUM_LEDS); 53 | // FastLED.addLeds(leds, NUM_LEDS); 54 | FastLED.addLeds(leds, NUM_LEDS); 55 | 56 | // FastLED.addLeds(leds, NUM_LEDS); 57 | // FastLED.addLeds(leds, NUM_LEDS); 58 | // FastLED.addLeds(leds, NUM_LEDS); 59 | } 60 | 61 | void loop() { 62 | leds[0] = CRGB(255,0,0); 63 | leds[1] = CRGB(0,255,0); 64 | leds[2] = CRGB(0,255,0); 65 | leds[3] = CRGB(0,0,255); 66 | leds[4] = CRGB(0,0,255); 67 | leds[5] = CRGB(0,0,255); 68 | leds[random8()%NUM_LEDS] = CRGB(0,0,0); 69 | // leds[10] = CRGB(0,0,0); 70 | FastLED.show(); 71 | // delay(1000); 72 | FastLED.showColor(CRGB::Black); 73 | } 74 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/ColorTemperature/ColorTemperature.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LED_PIN 3 4 | 5 | // Information about the LED strip itself 6 | #define NUM_LEDS 60 7 | #define CHIPSET WS2811 8 | #define COLOR_ORDER GRB 9 | CRGB leds[NUM_LEDS]; 10 | 11 | #define BRIGHTNESS 128 12 | 13 | 14 | // FastLED v2.1 provides two color-management controls: 15 | // (1) color correction settings for each LED strip, and 16 | // (2) master control of the overall output 'color temperature' 17 | // 18 | // THIS EXAMPLE demonstrates the second, "color temperature" control. 19 | // It shows a simple rainbow animation first with one temperature profile, 20 | // and a few seconds later, with a different temperature profile. 21 | // 22 | // The first pixel of the strip will show the color temperature. 23 | // 24 | // HELPFUL HINTS for "seeing" the effect in this demo: 25 | // * Don't look directly at the LED pixels. Shine the LEDs aganst 26 | // a white wall, table, or piece of paper, and look at the reflected light. 27 | // 28 | // * If you watch it for a bit, and then walk away, and then come back 29 | // to it, you'll probably be able to "see" whether it's currently using 30 | // the 'redder' or the 'bluer' temperature profile, even not counting 31 | // the lowest 'indicator' pixel. 32 | // 33 | // 34 | // FastLED provides these pre-conigured incandescent color profiles: 35 | // Candle, Tungsten40W, Tungsten100W, Halogen, CarbonArc, 36 | // HighNoonSun, DirectSunlight, OvercastSky, ClearBlueSky, 37 | // FastLED provides these pre-configured gaseous-light color profiles: 38 | // WarmFluorescent, StandardFluorescent, CoolWhiteFluorescent, 39 | // FullSpectrumFluorescent, GrowLightFluorescent, BlackLightFluorescent, 40 | // MercuryVapor, SodiumVapor, MetalHalide, HighPressureSodium, 41 | // FastLED also provides an "Uncorrected temperature" profile 42 | // UncorrectedTemperature; 43 | 44 | #define TEMPERATURE_1 Tungsten100W 45 | #define TEMPERATURE_2 OvercastSky 46 | 47 | // How many seconds to show each temperature before switching 48 | #define DISPLAYTIME 20 49 | // How many seconds to show black between switches 50 | #define BLACKTIME 3 51 | 52 | void loop() 53 | { 54 | // draw a generic, no-name rainbow 55 | static uint8_t starthue = 0; 56 | fill_rainbow( leds + 5, NUM_LEDS - 5, --starthue, 20); 57 | 58 | // Choose which 'color temperature' profile to enable. 59 | uint8_t secs = (millis() / 1000) % (DISPLAYTIME * 2); 60 | if( secs < DISPLAYTIME) { 61 | FastLED.setTemperature( TEMPERATURE_1 ); // first temperature 62 | leds[0] = TEMPERATURE_1; // show indicator pixel 63 | } else { 64 | FastLED.setTemperature( TEMPERATURE_2 ); // second temperature 65 | leds[0] = TEMPERATURE_2; // show indicator pixel 66 | } 67 | 68 | // Black out the LEDs for a few secnds between color changes 69 | // to let the eyes and brains adjust 70 | if( (secs % DISPLAYTIME) < BLACKTIME) { 71 | memset8( leds, 0, NUM_LEDS * sizeof(CRGB)); 72 | } 73 | 74 | FastLED.show(); 75 | FastLED.delay(8); 76 | } 77 | 78 | void setup() { 79 | delay( 3000 ); // power-up safety delay 80 | // It's important to set the color correction for your LED strip here, 81 | // so that colors can be more accurately rendered through the 'temperature' profiles 82 | FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalSMD5050 ); 83 | FastLED.setBrightness( BRIGHTNESS ); 84 | } 85 | 86 | -------------------------------------------------------------------------------- /Software/Python/bakebit_128_64_oled_shapes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit example for the basic functions of BakeBit 128x64 OLED (http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_OLED_128x64) 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. 6 | # You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 7 | # 8 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 9 | # 10 | ''' 11 | ## License 12 | 13 | The MIT License (MIT) 14 | 15 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 16 | Copyright (C) 2016 FriendlyARM 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy 19 | of this software and associated documentation files (the "Software"), to deal 20 | in the Software without restriction, including without limitation the rights 21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | copies of the Software, and to permit persons to whom the Software is 23 | furnished to do so, subject to the following conditions: 24 | 25 | The above copyright notice and this permission notice shall be included in 26 | all copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 34 | THE SOFTWARE. 35 | ''' 36 | 37 | import bakebit_128_64_oled as oled 38 | from PIL import Image 39 | from PIL import ImageFont 40 | from PIL import ImageDraw 41 | 42 | oled.init() #initialze SEEED OLED display 43 | 44 | oled.clearDisplay() #clear the screen and set start position to top left corner 45 | oled.setNormalDisplay() #Set display to normal mode (i.e non-inverse mode) 46 | oled.setHorizontalMode() 47 | 48 | width=128 49 | height=64 50 | 51 | image = Image.new('1', (width, height)) 52 | 53 | # Get drawing object to draw on image. 54 | draw = ImageDraw.Draw(image) 55 | 56 | # Draw a black filled box to clear the image. 57 | draw.rectangle((0,0,width,height), outline=0, fill=0) 58 | 59 | # Draw some shapes. 60 | # First define some constants to allow easy resizing of shapes. 61 | padding = 2 62 | shape_width = 20 63 | top = padding 64 | bottom = height-padding 65 | # Move left to right keeping track of the current x position for drawing shapes. 66 | x = padding 67 | # Draw an ellipse. 68 | draw.ellipse((x, top , x+shape_width, bottom), outline=255, fill=0) 69 | x += shape_width+padding 70 | # Draw a rectangle. 71 | draw.rectangle((x, top, x+shape_width, bottom), outline=255, fill=0) 72 | x += shape_width+padding 73 | # Draw a triangle. 74 | draw.polygon([(x, bottom), (x+shape_width/2, top), (x+shape_width, bottom)], outline=255, fill=0) 75 | x += shape_width+padding 76 | # Draw an X. 77 | draw.line((x, bottom, x+shape_width, top), fill=255) 78 | draw.line((x, top, x+shape_width, bottom), fill=255) 79 | x += shape_width+padding 80 | 81 | # Load default font. 82 | font = ImageFont.load_default() 83 | 84 | # Alternatively load a TTF font. Make sure the .ttf font file is in the same directory as the python script! 85 | # Some other nice fonts to try: http://www.dafont.com/bitmap.php 86 | #font = ImageFont.truetype('Minecraftia.ttf', 8) 87 | 88 | # Write two lines of text. 89 | draw.text((x, top), 'Hello', font=font, fill=255) 90 | draw.text((x, top+20), 'World!', font=font, fill=255) 91 | 92 | oled.drawImage(image) 93 | 94 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/FirstLight/FirstLight.ino: -------------------------------------------------------------------------------- 1 | // Use if you want to force the software SPI subsystem to be used for some reason (generally, you don't) 2 | // #define FASTLED_FORCE_SOFTWARE_SPI 3 | // Use if you want to force non-accelerated pin access (hint: you really don't, it breaks lots of things) 4 | // #define FASTLED_FORCE_SOFTWARE_SPI 5 | // #define FASTLED_FORCE_SOFTWARE_PINS 6 | #include "FastLED.h" 7 | 8 | /////////////////////////////////////////////////////////////////////////////////////////// 9 | // 10 | // Move a white dot along the strip of leds. This program simply shows how to configure the leds, 11 | // and then how to turn a single pixel white and then off, moving down the line of pixels. 12 | // 13 | 14 | // How many leds are in the strip? 15 | #define NUM_LEDS 60 16 | 17 | // Data pin that led data will be written out over 18 | #define DATA_PIN 3 19 | 20 | // Clock pin only needed for SPI based chipsets when not using hardware SPI 21 | //#define CLOCK_PIN 8 22 | 23 | // This is an array of leds. One item for each led in your strip. 24 | CRGB leds[NUM_LEDS]; 25 | 26 | // This function sets up the ledsand tells the controller about them 27 | void setup() { 28 | // sanity check delay - allows reprogramming if accidently blowing power w/leds 29 | delay(2000); 30 | 31 | // Uncomment one of the following lines for your leds arrangement. 32 | // FastLED.addLeds(leds, NUM_LEDS); 33 | // FastLED.addLeds(leds, NUM_LEDS); 34 | // FastLED.addLeds(leds, NUM_LEDS); 35 | FastLED.addLeds(leds, NUM_LEDS); 36 | // FastLED.addLeds(leds, NUM_LEDS); 37 | // FastLED.addLeds(leds, NUM_LEDS); 38 | // FastLED.addLeds(leds, NUM_LEDS); 39 | // FastLED.addLeds(leds, NUM_LEDS); 40 | // FastLED.addLeds(leds, NUM_LEDS); 41 | // FastLED.addLeds(leds, NUM_LEDS); 42 | // FastLED.addLeds(leds, NUM_LEDS); 43 | // FastLED.addLeds(leds, NUM_LEDS); 44 | // FastLED.addLeds(leds, NUM_LEDS); 45 | 46 | // FastLED.addLeds(leds, NUM_LEDS); 47 | // FastLED.addLeds(leds, NUM_LEDS); 48 | // FastLED.addLeds(leds, NUM_LEDS); 49 | // FastLED.addLeds(leds, NUM_LEDS); 50 | // FastLED.addLeds(leds, NUM_LEDS); 51 | // FastLED.addLeds(leds, NUM_LEDS); 52 | 53 | // FastLED.addLeds(leds, NUM_LEDS); 54 | // FastLED.addLeds(leds, NUM_LEDS); 55 | // FastLED.addLeds(leds, NUM_LEDS); 56 | // FastLED.addLeds(leds, NUM_LEDS); 57 | // FastLED.addLeds(leds, NUM_LEDS); 58 | // FastLED.addLeds(leds, NUM_LEDS); 59 | } 60 | 61 | // This function runs over and over, and is where you do the magic to light 62 | // your leds. 63 | void loop() { 64 | // Move a single white led 65 | for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) { 66 | // Turn our current led on to white, then show the leds 67 | leds[whiteLed] = CRGB::White; 68 | 69 | // Show the leds (only one of which is set to white, from above) 70 | FastLED.show(); 71 | 72 | // Wait a little bit 73 | delay(100); 74 | 75 | // Turn our current led back to black for the next loop around 76 | leds[whiteLed] = CRGB::Black; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Software/Python/bakebit_prj_SystemInfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit example for the basic functions of BakeBit 128x64 OLED 4 | # 5 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. 6 | # You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 7 | # 8 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 9 | # 10 | ''' 11 | ## License 12 | 13 | The MIT License (MIT) 14 | 15 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 16 | Copyright (C) 2016 FriendlyARM 17 | 18 | Permission is hereby granted, free of charge, to any person obtaining a copy 19 | of this software and associated documentation files (the "Software"), to deal 20 | in the Software without restriction, including without limitation the rights 21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 22 | copies of the Software, and to permit persons to whom the Software is 23 | furnished to do so, subject to the following conditions: 24 | 25 | The above copyright notice and this permission notice shall be included in 26 | all copies or substantial portions of the Software. 27 | 28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 34 | THE SOFTWARE. 35 | ''' 36 | 37 | import time 38 | import bakebit 39 | import os 40 | import psutil 41 | from math import log 42 | import multiprocessing 43 | import platform 44 | import socket 45 | import bakebit_128_64_oled as oled 46 | import socket 47 | import fcntl 48 | import struct 49 | 50 | def get_ip_address(ifname): 51 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 52 | return socket.inet_ntoa(fcntl.ioctl( 53 | s.fileno(), 54 | 0x8915, # SIOCGIFADDR 55 | struct.pack('256s', ifname[:15]) 56 | )[20:24]) 57 | 58 | oled.init() #initialze SEEED OLED display 59 | oled.clearDisplay() #clear the screen and set start position to top left corner 60 | oled.setNormalDisplay() #Set display to normal mode (i.e non-inverse mode) 61 | oled.setPageMode() #Set addressing mode to Page Mode 62 | 63 | byteunits = ('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB') 64 | def filesizeformat(value): 65 | exponent = int(log(value, 1024)) 66 | return "%.1f %s" % (float(value) / pow(1024, exponent), byteunits[exponent]) 67 | 68 | memUsage = psutil.virtual_memory() 69 | diskUsage = psutil.disk_usage('/') 70 | 71 | oled.setTextXY(0,0) 72 | oled.putString("%s" % get_ip_address('eth0')) 73 | 74 | oled.setTextXY(0,1) 75 | oled.putString("Mem:%s" % filesizeformat(memUsage.total)) 76 | 77 | oled.setTextXY(0,2) 78 | oled.putString("Usage:%d%%" % memUsage.percent) 79 | 80 | oled.setTextXY(0,3) 81 | oled.putString("Disk:%s" % filesizeformat(diskUsage.total)) 82 | 83 | oled.setTextXY(0,4) 84 | oled.putString("Usage:%d%%" % diskUsage.percent) 85 | 86 | oled.setTextXY(0,5) 87 | oled.putString("CPU:%s" % platform.processor()) 88 | 89 | oled.setTextXY(0,6) 90 | oled.putString("Cores:%d" % multiprocessing.cpu_count()) 91 | 92 | with open("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq") as f: 93 | freq = int(f.readlines()[0])/1000 94 | freqStr = "%d MHz" % freq 95 | if freq > 1000: 96 | freqStr = "%.1f GHz" % (float(freq)/1000.0) 97 | oled.setTextXY(0,7) 98 | oled.putString("Freq:%s" % freqStr) 99 | 100 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/Noise/Noise.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // 4 | // Mark's xy coordinate mapping code. See the XYMatrix for more information on it. 5 | // 6 | 7 | // Params for width and height 8 | const uint8_t kMatrixWidth = 16; 9 | const uint8_t kMatrixHeight = 16; 10 | #define MAX_DIMENSION ((kMatrixWidth>kMatrixHeight) ? kMatrixWidth : kMatrixHeight) 11 | #define NUM_LEDS (kMatrixWidth * kMatrixHeight) 12 | // Param for different pixel layouts 13 | const bool kMatrixSerpentineLayout = true; 14 | 15 | 16 | uint16_t XY( uint8_t x, uint8_t y) 17 | { 18 | uint16_t i; 19 | 20 | if( kMatrixSerpentineLayout == false) { 21 | i = (y * kMatrixWidth) + x; 22 | } 23 | 24 | if( kMatrixSerpentineLayout == true) { 25 | if( y & 0x01) { 26 | // Odd rows run backwards 27 | uint8_t reverseX = (kMatrixWidth - 1) - x; 28 | i = (y * kMatrixWidth) + reverseX; 29 | } else { 30 | // Even rows run forwards 31 | i = (y * kMatrixWidth) + x; 32 | } 33 | } 34 | 35 | return i; 36 | } 37 | 38 | // The leds 39 | CRGB leds[kMatrixWidth * kMatrixHeight]; 40 | 41 | // The 32bit version of our coordinates 42 | static uint16_t x; 43 | static uint16_t y; 44 | static uint16_t z; 45 | 46 | // We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll 47 | // use the z-axis for "time". speed determines how fast time moves forward. Try 48 | // 1 for a very slow moving effect, or 60 for something that ends up looking like 49 | // water. 50 | // uint16_t speed = 1; // almost looks like a painting, moves very slowly 51 | uint16_t speed = 20; // a nice starting speed, mixes well with a scale of 100 52 | // uint16_t speed = 33; 53 | // uint16_t speed = 100; // wicked fast! 54 | 55 | // Scale determines how far apart the pixels in our noise matrix are. Try 56 | // changing these values around to see how it affects the motion of the display. The 57 | // higher the value of scale, the more "zoomed out" the noise iwll be. A value 58 | // of 1 will be so zoomed in, you'll mostly see solid colors. 59 | 60 | // uint16_t scale = 1; // mostly just solid colors 61 | // uint16_t scale = 4011; // very zoomed out and shimmery 62 | uint16_t scale = 311; 63 | 64 | // This is the array that we keep our computed noise values in 65 | uint8_t noise[MAX_DIMENSION][MAX_DIMENSION]; 66 | 67 | void setup() { 68 | // uncomment the following lines if you want to see FPS count information 69 | // Serial.begin(38400); 70 | // Serial.println("resetting!"); 71 | delay(3000); 72 | LEDS.addLeds(leds,NUM_LEDS); 73 | LEDS.setBrightness(96); 74 | 75 | // Initialize our coordinates to some random values 76 | x = random16(); 77 | y = random16(); 78 | z = random16(); 79 | } 80 | 81 | // Fill the x/y array of 8-bit noise values using the inoise8 function. 82 | void fillnoise8() { 83 | for(int i = 0; i < MAX_DIMENSION; i++) { 84 | int ioffset = scale * i; 85 | for(int j = 0; j < MAX_DIMENSION; j++) { 86 | int joffset = scale * j; 87 | noise[i][j] = inoise8(x + ioffset,y + joffset,z); 88 | } 89 | } 90 | z += speed; 91 | } 92 | 93 | 94 | void loop() { 95 | static uint8_t ihue=0; 96 | fillnoise8(); 97 | for(int i = 0; i < kMatrixWidth; i++) { 98 | for(int j = 0; j < kMatrixHeight; j++) { 99 | // We use the value at the (i,j) coordinate in the noise 100 | // array for our brightness, and the flipped value from (j,i) 101 | // for our pixel's hue. 102 | leds[XY(i,j)] = CHSV(noise[j][i],255,noise[i][j]); 103 | 104 | // You can also explore other ways to constrain the hue used, like below 105 | // leds[XY(i,j)] = CHSV(ihue + (noise[j][i]>>2),255,noise[i][j]); 106 | } 107 | } 108 | ihue+=1; 109 | 110 | LEDS.show(); 111 | // delay(10); 112 | } 113 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/release_notes.md: -------------------------------------------------------------------------------- 1 | FastLED3.0 2 | ========== 3 | 4 | * Added support for the following platforms: 5 | * Arduino due 6 | * Teensy 3.1 7 | * Added the following LED chipsets: 8 | * USC1903_400 9 | * GW6205 / GW6205_400 10 | * APA102 11 | * APA104 12 | * LPD1886 13 | * P9813 14 | * SmartMatrix 15 | * Added multiple examples: 16 | * ColorPalette - show off the color palette code 17 | * ColorTemperature - show off the color correction code 18 | * Fire2012 19 | * Fire2012WithPalette 20 | * Multiple led controller examples 21 | * Noise 22 | * NoisePlayground 23 | * NoisePlusPalette 24 | * SmartMatrix - show off SmartMatrix support 25 | * XYMatrix - show how to use a mtrix layout of leds 26 | * Added color correction 27 | * Added dithering 28 | * Added power management support 29 | * Added support for color palettes 30 | * Added easing functions 31 | * Added fast trig functions 32 | * Added simplex noise functions 33 | * Added color utility functions 34 | * Fixed DMXSERIAL/DMXSIMPLE support 35 | * Timing adjustments for existing SPI chipsets 36 | * Cleaned up the code layout to make platform support easier 37 | * Many bug fixes 38 | * A number of performance/memory improvements 39 | * Remove Squant (takes up space!) 40 | 41 | FastLED2 42 | ======== 43 | 44 | ## Full release of the library 45 | 46 | ## Release Candidate 6 47 | * Rename library, offically, to FastLED, move to github 48 | * Update keywords with all the new stuffs 49 | 50 | ## Release Candidate 5 51 | * Gemma and Trinket: supported except for global "setBrightness" 52 | 53 | ## Release Candidate 4 54 | * Added NEOPIXEL as a synonym for WS2811 55 | * Fix WS2811/WS2812B timings, bring it in line to exactly 1.25ns/bit. 56 | * Fix handling of constant color definitions (damn you, gcc!) 57 | 58 | ## Release Candidate 3 59 | * Fixed bug when Clock and Data were on the same port 60 | * Added ability to set pixel color directly from HSV 61 | * Added ability to retrieve current random16 seed 62 | 63 | ## Release Candidate 2 64 | * mostly bug fixes 65 | * Fix SPI macro definitions for latest teensy3 software update 66 | * Teensy 2 compilation fix 67 | * hsv2rgb_rainbow performance fix 68 | 69 | ## Release Candidate 1 70 | * New unified/simplified API for adding/using controllers 71 | * fleshout clockless chip support 72 | * add hsv (spectrum and rainbow style colors) 73 | * high speed memory management operations 74 | * library for interpolation/easing functions 75 | * various api changes, addition of clear and showColor functions 76 | * scale value applied to all show methods 77 | * bug fixes for SM16716 78 | * performance improvements, lpd8806 exceeds 22Mbit now 79 | * hardware def fixes 80 | * allow alternate rgb color orderings 81 | * high speed math methods 82 | * rich CRGB structure 83 | 84 | ## Preview 3 85 | * True hardware SPI support for teensy (up to 20Mbit output!) 86 | * Minor bug fixes/tweaks 87 | 88 | ## Preview 2 89 | * Rename pin class to FastPin 90 | * Replace latch with select, more accurate description of what it does 91 | * Enforce intra-frame timing for ws2801s 92 | * SM16716 support 93 | * Add #define FAST_SPI_INTERRUPTS_WRITE_PINS to make sure world is ok w/interrupts and SPI 94 | * Add #define FASTLED_FORCE_SOFTWARE_SPI for those times when you absolutely don't want to use hardware SPI, ev 95 | en if you're using the hardware SPI pins 96 | * Add pin definitions for the arduino megas - should fix ws2811 support 97 | * Add pin definitions for the leonardo - should fix spi support and pin mappings 98 | * Add warnings when pin definitions are missing 99 | * Added google+ community for fastspi users - https://plus.google.com/communities/109127054924227823508 100 | # Add pin definitions for Teensy++ 2.0 101 | 102 | 103 | ## Preview 1 104 | * Initial release 105 | 106 | 107 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/Fire2012/Fire2012.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LED_PIN 5 4 | #define COLOR_ORDER GRB 5 | #define CHIPSET WS2811 6 | #define NUM_LEDS 30 7 | 8 | #define BRIGHTNESS 200 9 | #define FRAMES_PER_SECOND 60 10 | 11 | bool gReverseDirection = false; 12 | 13 | CRGB leds[NUM_LEDS]; 14 | 15 | void setup() { 16 | delay(3000); // sanity delay 17 | FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); 18 | FastLED.setBrightness( BRIGHTNESS ); 19 | } 20 | 21 | void loop() 22 | { 23 | // Add entropy to random number generator; we use a lot of it. 24 | // random16_add_entropy( random()); 25 | 26 | Fire2012(); // run simulation frame 27 | 28 | FastLED.show(); // display this frame 29 | FastLED.delay(1000 / FRAMES_PER_SECOND); 30 | } 31 | 32 | 33 | // Fire2012 by Mark Kriegsman, July 2012 34 | // as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY 35 | //// 36 | // This basic one-dimensional 'fire' simulation works roughly as follows: 37 | // There's a underlying array of 'heat' cells, that model the temperature 38 | // at each point along the line. Every cycle through the simulation, 39 | // four steps are performed: 40 | // 1) All cells cool down a little bit, losing heat to the air 41 | // 2) The heat from each cell drifts 'up' and diffuses a little 42 | // 3) Sometimes randomly new 'sparks' of heat are added at the bottom 43 | // 4) The heat from each cell is rendered as a color into the leds array 44 | // The heat-to-color mapping uses a black-body radiation approximation. 45 | // 46 | // Temperature is in arbitrary units from 0 (cold black) to 255 (white hot). 47 | // 48 | // This simulation scales it self a bit depending on NUM_LEDS; it should look 49 | // "OK" on anywhere from 20 to 100 LEDs without too much tweaking. 50 | // 51 | // I recommend running this simulation at anywhere from 30-100 frames per second, 52 | // meaning an interframe delay of about 10-35 milliseconds. 53 | // 54 | // Looks best on a high-density LED setup (60+ pixels/meter). 55 | // 56 | // 57 | // There are two main parameters you can play with to control the look and 58 | // feel of your fire: COOLING (used in step 1 above), and SPARKING (used 59 | // in step 3 above). 60 | // 61 | // COOLING: How much does the air cool as it rises? 62 | // Less cooling = taller flames. More cooling = shorter flames. 63 | // Default 50, suggested range 20-100 64 | #define COOLING 55 65 | 66 | // SPARKING: What chance (out of 255) is there that a new spark will be lit? 67 | // Higher chance = more roaring fire. Lower chance = more flickery fire. 68 | // Default 120, suggested range 50-200. 69 | #define SPARKING 120 70 | 71 | 72 | void Fire2012() 73 | { 74 | // Array of temperature readings at each simulation cell 75 | static byte heat[NUM_LEDS]; 76 | 77 | // Step 1. Cool down every cell a little 78 | for( int i = 0; i < NUM_LEDS; i++) { 79 | heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2)); 80 | } 81 | 82 | // Step 2. Heat from each cell drifts 'up' and diffuses a little 83 | for( int k= NUM_LEDS - 1; k >= 2; k--) { 84 | heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; 85 | } 86 | 87 | // Step 3. Randomly ignite new 'sparks' of heat near the bottom 88 | if( random8() < SPARKING ) { 89 | int y = random8(7); 90 | heat[y] = qadd8( heat[y], random8(160,255) ); 91 | } 92 | 93 | // Step 4. Map from heat cells to LED colors 94 | for( int j = 0; j < NUM_LEDS; j++) { 95 | CRGB color = HeatColor( heat[j]); 96 | int pixelnumber; 97 | if( gReverseDirection ) { 98 | pixelnumber = (NUM_LEDS-1) - j; 99 | } else { 100 | pixelnumber = j; 101 | } 102 | leds[pixelnumber] = color; 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/hsv2rgb.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_HSV2RGB_H 2 | #define __INC_HSV2RGB_H 3 | 4 | #include "pixeltypes.h" 5 | 6 | FASTLED_NAMESPACE_BEGIN 7 | 8 | // hsv2rgb_rainbow - convert a hue, saturation, and value to RGB 9 | // using a visually balanced rainbow (vs a straight 10 | // mathematical spectrum). 11 | // This 'rainbow' yields better yellow and orange 12 | // than a straight 'spectrum'. 13 | // 14 | // NOTE: here hue is 0-255, not just 0-191 15 | 16 | void hsv2rgb_rainbow( const struct CHSV& hsv, struct CRGB& rgb); 17 | void hsv2rgb_rainbow( const struct CHSV* phsv, struct CRGB * prgb, int numLeds); 18 | #define HUE_MAX_RAINBOW 255 19 | 20 | 21 | // hsv2rgb_spectrum - convert a hue, saturation, and value to RGB 22 | // using a mathematically straight spectrum (vs 23 | // a visually balanced rainbow). 24 | // This 'spectrum' will have more green & blue 25 | // than a 'rainbow', and less yellow and orange. 26 | // 27 | // NOTE: here hue is 0-255, not just 0-191 28 | 29 | void hsv2rgb_spectrum( const struct CHSV& hsv, struct CRGB& rgb); 30 | void hsv2rgb_spectrum( const struct CHSV* phsv, struct CRGB * prgb, int numLeds); 31 | #define HUE_MAX_SPECTRUM 255 32 | 33 | 34 | // hsv2rgb_raw - convert hue, saturation, and value to RGB. 35 | // This 'spectrum' conversion will be more green & blue 36 | // than a real 'rainbow', and the hue is specified just 37 | // in the range 0-191. Together, these result in a 38 | // slightly faster conversion speed, at the expense of 39 | // color balance. 40 | // 41 | // NOTE: Hue is 0-191 only! 42 | // Saturation & value are 0-255 each. 43 | // 44 | 45 | void hsv2rgb_raw(const struct CHSV& hsv, struct CRGB & rgb); 46 | void hsv2rgb_raw(const struct CHSV* phsv, struct CRGB * prgb, int numLeds); 47 | #define HUE_MAX 191 48 | 49 | 50 | // rgb2hsv_approximate - recover _approximate_ HSV values from RGB. 51 | // 52 | // NOTE 1: This function is a long-term work in process; expect 53 | // results to change slightly over time as this function is 54 | // refined and improved. 55 | // 56 | // NOTE 2: This function is most accurate when the input is an 57 | // RGB color that came from a fully-saturated HSV color to start 58 | // with. E.g. CHSV( hue, 255, 255) -> CRGB -> CHSV will give 59 | // best results. 60 | // 61 | // NOTE 3: This function is not nearly as fast as HSV-to-RGB. 62 | // It is provided for those situations when the need for this 63 | // function cannot be avoided, or when extremely high performance 64 | // is not needed. 65 | // 66 | // NOTE 4: Why is this 'only' an "approximation"? 67 | // Not all RGB colors have HSV equivalents! For example, there 68 | // is no HSV value that will ever convert to RGB(255,255,0) using 69 | // the code provided in this library. So if you try to 70 | // convert RGB(255,255,0) 'back' to HSV, you'll necessarily get 71 | // only an approximation. Emphasis has been placed on getting 72 | // the 'hue' as close as usefully possible, but even that's a bit 73 | // of a challenge. The 8-bit HSV and 8-bit RGB color spaces 74 | // are not a "bijection". 75 | // 76 | // Nevertheless, this function does a pretty good job, particularly 77 | // at recovering the 'hue' from fully saturated RGB colors that 78 | // originally came from HSV rainbow colors. So if you start 79 | // with CHSV(hue_in,255,255), and convert that to RGB, and then 80 | // convert it back to HSV using this function, the resulting output 81 | // hue will either exactly the same, or very close (+/-1). 82 | // The more desaturated the original RGB color is, the rougher the 83 | // approximation, and the less accurate the results. 84 | // 85 | CHSV rgb2hsv_approximate( const CRGB& rgb); 86 | 87 | FASTLED_NAMESPACE_END 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/platforms/arm/nrf51/clockless_arm_nrf51.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_CLOCKLESS_ARM_NRF51 2 | #define __INC_CLOCKLESS_ARM_NRF51 3 | 4 | #if defined(NRF51) 5 | 6 | #include "nrf51_bitfields.h" 7 | #define FASTLED_HAS_CLOCKLESS 1 8 | 9 | #if (FASTLED_ALLOW_INTERRUPTS==1) 10 | #define SEI_CHK LED_TIMER->CC[0] = (WAIT_TIME * (F_CPU/1000000)); LED_TIMER->TASKS_CLEAR; LED_TIMER->EVENTS_COMPARE[0] = 0; 11 | #define CLI_CHK cli(); if(LED_TIMER->EVENTS_COMPARE[0]) { LED_TIMER->TASKS_STOP = 1; return 0; } 12 | #define INNER_SEI sei(); 13 | #else 14 | #define SEI_CHK 15 | #define CLI_CHK 16 | #define INNER_SEI delaycycles<1>(); 17 | #endif 18 | 19 | 20 | #include "platforms/arm/common/m0clockless.h" 21 | template 22 | class ClocklessController : public CLEDController { 23 | typedef typename FastPinBB::port_ptr_t data_ptr_t; 24 | typedef typename FastPinBB::port_t data_t; 25 | 26 | data_t mPinMask; 27 | data_ptr_t mPort; 28 | CMinWait mWait; 29 | public: 30 | virtual void init() { 31 | FastPinBB::setOutput(); 32 | mPinMask = FastPinBB::mask(); 33 | mPort = FastPinBB::port(); 34 | } 35 | 36 | virtual uint16_t getMaxRefreshRate() const { return 400; } 37 | 38 | virtual void clearLeds(int nLeds) { 39 | showColor(CRGB(0, 0, 0), nLeds, 0); 40 | } 41 | 42 | // set all the leds on the controller to a given color 43 | virtual void showColor(const struct CRGB & rgbdata, int nLeds, CRGB scale) { 44 | PixelController pixels(rgbdata, nLeds, scale, getDither()); 45 | mWait.wait(); 46 | cli(); 47 | 48 | // attempt to re-show a frame if we exit early because of interrupts. 49 | if(!showRGBInternal(pixels)) { 50 | sei(); delayMicroseconds(WAIT_TIME); cli(); 51 | showRGBInternal(pixels); 52 | } 53 | 54 | sei(); 55 | mWait.mark(); 56 | } 57 | 58 | virtual void show(const struct CRGB *rgbdata, int nLeds, CRGB scale) { 59 | PixelController pixels(rgbdata, nLeds, scale, getDither()); 60 | mWait.wait(); 61 | cli(); 62 | 63 | if(!showRGBInternal(pixels)) { 64 | sei(); delayMicroseconds(WAIT_TIME); cli(); 65 | showRGBInternal(pixels); 66 | } 67 | 68 | sei(); 69 | mWait.mark(); 70 | } 71 | 72 | #ifdef SUPPORT_ARGB 73 | virtual void show(const struct CARGB *rgbdata, int nLeds, CRGB scale) { 74 | PixelController pixels(rgbdata, nLeds, scale, getDither()); 75 | mWait.wait(); 76 | cli(); 77 | showRGBInternal(pixels); 78 | sei(); 79 | mWait.mark(); 80 | } 81 | #endif 82 | 83 | // This method is made static to force making register Y available to use for data on AVR - if the method is non-static, then 84 | // gcc will use register Y for the this pointer. 85 | static uint32_t showRGBInternal(PixelController & pixels) { 86 | struct M0ClocklessData data; 87 | data.d[0] = pixels.d[0]; 88 | data.d[1] = pixels.d[1]; 89 | data.d[2] = pixels.d[2]; 90 | data.s[0] = pixels.mScale[0]; 91 | data.s[1] = pixels.mScale[1]; 92 | data.s[2] = pixels.mScale[2]; 93 | data.e[0] = pixels.e[0]; 94 | data.e[1] = pixels.e[1]; 95 | data.e[2] = pixels.e[2]; 96 | data.adj = pixels.mAdvance; 97 | 98 | typename FastPin::port_ptr_t portBase = FastPin::port(); 99 | 100 | // timer mode w/prescaler of 0 101 | LED_TIMER->MODE = TIMER_MODE_MODE_Timer; 102 | LED_TIMER->PRESCALER = 0; 103 | LED_TIMER->EVENTS_COMPARE[0] = 0; 104 | LED_TIMER->BITMODE = TIMER_BITMODE_BITMODE_16Bit; 105 | LED_TIMER->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Msk; 106 | LED_TIMER->TASKS_START = 1; 107 | 108 | int ret = showLedData<4,8,T1,T2,T3,RGB_ORDER,WAIT_TIME>(portBase, FastPin::mask(), pixels.mData, pixels.mLen, &data); 109 | 110 | LED_TIMER->TASKS_STOP = 1; 111 | return ret; // 0x00FFFFFF - _VAL; 112 | } 113 | }; 114 | 115 | 116 | #endif // NRF51 117 | #endif // __INC_CLOCKLESS_ARM_NRF51 118 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/DemoReel100/DemoReel100.ino: -------------------------------------------------------------------------------- 1 | #include "FastLED.h" 2 | 3 | FASTLED_USING_NAMESPACE 4 | 5 | // FastLED "100-lines-of-code" demo reel, showing just a few 6 | // of the kinds of animation patterns you can quickly and easily 7 | // compose using FastLED. 8 | // 9 | // This example also shows one easy way to define multiple 10 | // animations patterns and have them automatically rotate. 11 | // 12 | // -Mark Kriegsman, December 2014 13 | 14 | #if FASTLED_VERSION < 3001000 15 | #error "Requires FastLED 3.1 or later; check github for latest code." 16 | #endif 17 | 18 | #define DATA_PIN 3 19 | //#define CLK_PIN 4 20 | #define LED_TYPE WS2811 21 | #define COLOR_ORDER GRB 22 | #define NUM_LEDS 64 23 | CRGB leds[NUM_LEDS]; 24 | 25 | #define BRIGHTNESS 96 26 | #define FRAMES_PER_SECOND 120 27 | 28 | void setup() { 29 | delay(3000); // 3 second delay for recovery 30 | 31 | // tell FastLED about the LED strip configuration 32 | FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); 33 | //FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); 34 | 35 | // set master brightness control 36 | FastLED.setBrightness(BRIGHTNESS); 37 | } 38 | 39 | 40 | // List of patterns to cycle through. Each is defined as a separate function below. 41 | typedef void (*SimplePatternList[])(); 42 | SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm }; 43 | 44 | uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current 45 | uint8_t gHue = 0; // rotating "base color" used by many of the patterns 46 | 47 | void loop() 48 | { 49 | // Call the current pattern function once, updating the 'leds' array 50 | gPatterns[gCurrentPatternNumber](); 51 | 52 | // send the 'leds' array out to the actual LED strip 53 | FastLED.show(); 54 | // insert a delay to keep the framerate modest 55 | FastLED.delay(1000/FRAMES_PER_SECOND); 56 | 57 | // do some periodic updates 58 | EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow 59 | EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically 60 | } 61 | 62 | #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0])) 63 | 64 | void nextPattern() 65 | { 66 | // add one to the current pattern number, and wrap around at the end 67 | gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns); 68 | } 69 | 70 | void rainbow() 71 | { 72 | // FastLED's built-in rainbow generator 73 | fill_rainbow( leds, NUM_LEDS, gHue, 7); 74 | } 75 | 76 | void rainbowWithGlitter() 77 | { 78 | // built-in FastLED rainbow, plus some random sparkly glitter 79 | rainbow(); 80 | addGlitter(80); 81 | } 82 | 83 | void addGlitter( fract8 chanceOfGlitter) 84 | { 85 | if( random8() < chanceOfGlitter) { 86 | leds[ random16(NUM_LEDS) ] += CRGB::White; 87 | } 88 | } 89 | 90 | void confetti() 91 | { 92 | // random colored speckles that blink in and fade smoothly 93 | fadeToBlackBy( leds, NUM_LEDS, 10); 94 | int pos = random16(NUM_LEDS); 95 | leds[pos] += CHSV( gHue + random8(64), 200, 255); 96 | } 97 | 98 | void sinelon() 99 | { 100 | // a colored dot sweeping back and forth, with fading trails 101 | fadeToBlackBy( leds, NUM_LEDS, 20); 102 | int pos = beatsin16(13,0,NUM_LEDS); 103 | leds[pos] += CHSV( gHue, 255, 192); 104 | } 105 | 106 | void bpm() 107 | { 108 | // colored stripes pulsing at a defined Beats-Per-Minute (BPM) 109 | uint8_t BeatsPerMinute = 62; 110 | CRGBPalette16 palette = PartyColors_p; 111 | uint8_t beat = beatsin8( BeatsPerMinute, 64, 255); 112 | for( int i = 0; i < NUM_LEDS; i++) { //9948 113 | leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10)); 114 | } 115 | } 116 | 117 | void juggle() { 118 | // eight colored dots, weaving in and out of sync with each other 119 | fadeToBlackBy( leds, NUM_LEDS, 20); 120 | byte dothue = 0; 121 | for( int i = 0; i < 8; i++) { 122 | leds[beatsin16(i+7,0,NUM_LEDS)] |= CHSV(dothue, 200, 255); 123 | dothue += 32; 124 | } 125 | } 126 | 127 | -------------------------------------------------------------------------------- /Software/Python/bakebit_prj_SmartLighting.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # BakeBit Example for using the BakeBit Light Sensor and the LED Bar together to turn the LED Bar On and OFF. 4 | # Modules: 5 | # http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Light_Sensor 6 | # http://wiki.friendlyarm.com/wiki/index.php/BakeBit_-_Red_LED 7 | # 8 | # The BakeBit connects the NanoPi NEO and BakeBit sensors. 9 | # You can learn more about BakeBit here: http://wiki.friendlyarm.com/BakeBit 10 | # 11 | # Have a question about this example? Ask on the forums here: http://www.friendlyarm.com/Forum/ 12 | # 13 | ''' 14 | ## License 15 | 16 | The MIT License (MIT) 17 | 18 | BakeBit: an open source platform for connecting BakeBit Sensors to the NanoPi NEO. 19 | Copyright (C) 2016 FriendlyARM 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in 29 | all copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 37 | THE SOFTWARE. 38 | ''' 39 | 40 | import time 41 | import bakebit 42 | 43 | # Connect the BakeBit Light Sensor to analog port A0 44 | # SIG,NC,VCC,GND 45 | light_sensor = 0 46 | 47 | # Connect the BakeBit LED Bar to digital port D3 48 | # DI,DCKI,VCC,GND 49 | ledbar = 3 50 | 51 | 52 | lowThreshold = 500 53 | highTreshold = 600 54 | 55 | bakebit.pinMode(light_sensor,"INPUT") 56 | bakebit.pinMode(ledbar,"OUTPUT") 57 | time.sleep(.2) 58 | bakebit.bakeBitLedBar_Init(ledbar, 0, 5) 59 | time.sleep(.5) 60 | old_color = 0 61 | 62 | while True: 63 | try: 64 | light_count = 0 65 | 66 | # Get sensor value 67 | sensor_value = bakebit.analogRead(light_sensor) 68 | if sensor_value > highTreshold: 69 | f=(1023-highTreshold)/4 70 | light_count = (sensor_value-highTreshold)/f+1 71 | 72 | # turn on ledbar 73 | color16bit = bakebit.Green 74 | if light_count > 1: 75 | color16bit = color16bit | (bakebit.Green << 3) 76 | if light_count > 2: 77 | color16bit = color16bit | (bakebit.Green << 6) 78 | if light_count > 3: 79 | color16bit = color16bit | (bakebit.Green << 9) 80 | if light_count > 4: 81 | color16bit = 0 82 | color16bit = color16bit | bakebit.Blue 83 | color16bit = color16bit | (bakebit.Blue << 3) 84 | color16bit = color16bit | (bakebit.Blue << 6) 85 | color16bit = color16bit | (bakebit.Blue << 9) 86 | color16bit = color16bit | (bakebit.Blue << 12) 87 | 88 | if color16bit != old_color: 89 | old_color = color16bit 90 | lowBits = color16bit & 255 91 | highBits = (color16bit & (255 << 8)) >> 8 92 | bakebit.bakeBitLedBar_Show(ledbar, highBits, lowBits) 93 | 94 | elif sensor_value < lowThreshold: 95 | # turn off ledbar 96 | bakebit.bakeBitLedBar_Show(ledbar, 0, 0) 97 | 98 | print("sensor_value = %d light_count =%d" %(sensor_value, light_count)) 99 | time.sleep(.5) 100 | 101 | except KeyboardInterrupt: 102 | bakebit.bakeBitLedBar_Release(ledbar) 103 | time.sleep(.2) 104 | break 105 | except IOError: 106 | print ("Error") 107 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/examples/SmartMatrix/SmartMatrix.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define kMatrixWidth 32 5 | #define kMatrixHeight 32 6 | const bool kMatrixSerpentineLayout = false; 7 | 8 | #define NUM_LEDS (kMatrixWidth * kMatrixHeight) 9 | 10 | CRGB leds[kMatrixWidth * kMatrixHeight]; 11 | 12 | 13 | uint16_t XY( uint8_t x, uint8_t y) 14 | { 15 | uint16_t i; 16 | 17 | if( kMatrixSerpentineLayout == false) { 18 | i = (y * kMatrixWidth) + x; 19 | } 20 | 21 | if( kMatrixSerpentineLayout == true) { 22 | if( y & 0x01) { 23 | // Odd rows run backwards 24 | uint8_t reverseX = (kMatrixWidth - 1) - x; 25 | i = (y * kMatrixWidth) + reverseX; 26 | } else { 27 | // Even rows run forwards 28 | i = (y * kMatrixWidth) + x; 29 | } 30 | } 31 | 32 | return i; 33 | } 34 | 35 | // The 32bit version of our coordinates 36 | static uint16_t x; 37 | static uint16_t y; 38 | static uint16_t z; 39 | 40 | // We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll 41 | // use the z-axis for "time". speed determines how fast time moves forward. Try 42 | // 1 for a very slow moving effect, or 60 for something that ends up looking like 43 | // water. 44 | // uint16_t speed = 1; // almost looks like a painting, moves very slowly 45 | uint16_t speed = 20; // a nice starting speed, mixes well with a scale of 100 46 | // uint16_t speed = 33; 47 | // uint16_t speed = 100; // wicked fast! 48 | 49 | // Scale determines how far apart the pixels in our noise matrix are. Try 50 | // changing these values around to see how it affects the motion of the display. The 51 | // higher the value of scale, the more "zoomed out" the noise iwll be. A value 52 | // of 1 will be so zoomed in, you'll mostly see solid colors. 53 | 54 | // uint16_t scale = 1; // mostly just solid colors 55 | // uint16_t scale = 4011; // very zoomed out and shimmery 56 | uint16_t scale = 31; 57 | 58 | // This is the array that we keep our computed noise values in 59 | uint8_t noise[kMatrixWidth][kMatrixHeight]; 60 | 61 | void setup() { 62 | // uncomment the following lines if you want to see FPS count information 63 | // Serial.begin(38400); 64 | // Serial.println("resetting!"); 65 | delay(3000); 66 | LEDS.addLeds(leds,NUM_LEDS); 67 | LEDS.setBrightness(96); 68 | 69 | // Initialize our coordinates to some random values 70 | x = random16(); 71 | y = random16(); 72 | z = random16(); 73 | 74 | // Show off smart matrix scrolling text 75 | pSmartMatrix->setScrollMode(wrapForward); 76 | pSmartMatrix->setScrollColor({0xff, 0xff, 0xff}); 77 | pSmartMatrix->setScrollSpeed(15); 78 | pSmartMatrix->setScrollFont(font6x10); 79 | pSmartMatrix->scrollText("Smart Matrix & FastLED", -1); 80 | pSmartMatrix->setScrollOffsetFromEdge(10); 81 | } 82 | 83 | // Fill the x/y array of 8-bit noise values using the inoise8 function. 84 | void fillnoise8() { 85 | for(int i = 0; i < kMatrixWidth; i++) { 86 | int ioffset = scale * i; 87 | for(int j = 0; j < kMatrixHeight; j++) { 88 | int joffset = scale * j; 89 | noise[i][j] = inoise8(x + ioffset,y + joffset,z); 90 | } 91 | } 92 | z += speed; 93 | } 94 | 95 | 96 | void loop() { 97 | static uint8_t circlex = 0; 98 | static uint8_t circley = 0; 99 | 100 | static uint8_t ihue=0; 101 | fillnoise8(); 102 | for(int i = 0; i < kMatrixWidth; i++) { 103 | for(int j = 0; j < kMatrixHeight; j++) { 104 | // We use the value at the (i,j) coordinate in the noise 105 | // array for our brightness, and the flipped value from (j,i) 106 | // for our pixel's hue. 107 | leds[XY(i,j)] = CHSV(noise[j][i],255,noise[i][j]); 108 | 109 | // You can also explore other ways to constrain the hue used, like below 110 | // leds[XY(i,j)] = CHSV(ihue + (noise[j][i]>>2),255,noise[i][j]); 111 | } 112 | } 113 | ihue+=1; 114 | 115 | // N.B. this requires SmartMatrix modified w/triple buffering support 116 | pSmartMatrix->fillCircle(circlex % 32,circley % 32,6,CRGB(CHSV(ihue+128,255,255))); 117 | circlex += random16(2); 118 | circley += random16(2); 119 | LEDS.show(); 120 | // delay(10); 121 | } 122 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/FastLED-FastLED3.1/fastspi.h: -------------------------------------------------------------------------------- 1 | #ifndef __INC_FASTSPI_H 2 | #define __INC_FASTSPI_H 3 | 4 | #include "controller.h" 5 | #include "lib8tion.h" 6 | 7 | #include "fastspi_bitbang.h" 8 | 9 | FASTLED_NAMESPACE_BEGIN 10 | 11 | #if defined(FASTLED_TEENSY3) && (F_CPU > 48000000) 12 | #define DATA_RATE_MHZ(X) (((48000000L / 1000000L) / X)) 13 | #define DATA_RATE_KHZ(X) (((48000000L / 1000L) / X)) 14 | #else 15 | #define DATA_RATE_MHZ(X) ((F_CPU / 1000000L) / X) 16 | #define DATA_RATE_KHZ(X) ((F_CPU / 1000L) / X) 17 | #endif 18 | 19 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 20 | // 21 | // External SPI template definition with partial instantiation(s) to map to hardware SPI ports on platforms/builds where the pin 22 | // mappings are known at compile time. 23 | // 24 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 25 | 26 | template 27 | class SPIOutput : public AVRSoftwareSPIOutput<_DATA_PIN, _CLOCK_PIN, _SPI_CLOCK_DIVIDER> {}; 28 | 29 | template 30 | class SoftwareSPIOutput : public AVRSoftwareSPIOutput<_DATA_PIN, _CLOCK_PIN, _SPI_CLOCK_DIVIDER> {}; 31 | 32 | #ifndef FASTLED_FORCE_SOFTWARE_SPI 33 | #if defined(SPI_DATA) && defined(SPI_CLOCK) 34 | 35 | #if defined(FASTLED_TEENSY3) && defined(ARM_HARDWARE_SPI) 36 | 37 | template 38 | class SPIOutput : public ARMHardwareSPIOutput {}; 39 | 40 | #if defined(SPI2_DATA) 41 | 42 | template 43 | class SPIOutput : public ARMHardwareSPIOutput {}; 44 | 45 | template 46 | class SPIOutput : public ARMHardwareSPIOutput {}; 47 | 48 | template 49 | class SPIOutput : public ARMHardwareSPIOutput {}; 50 | #endif 51 | 52 | #elif defined(FASTLED_TEENSYLC) && defined(ARM_HARDWARE_SPI) 53 | 54 | #define DECLARE_SPI0(__DATA,__CLOCK) template\ 55 | class SPIOutput<__DATA, __CLOCK, SPI_SPEED> : public ARMHardwareSPIOutput<__DATA, __CLOCK, SPI_SPEED, 0x40076000> {}; 56 | #define DECLARE_SPI1(__DATA,__CLOCK) template\ 57 | class SPIOutput<__DATA, __CLOCK, SPI_SPEED> : public ARMHardwareSPIOutput<__DATA, __CLOCK, SPI_SPEED, 0x40077000> {}; 58 | 59 | DECLARE_SPI0(7,13); 60 | DECLARE_SPI0(8,13); 61 | DECLARE_SPI0(11,13); 62 | DECLARE_SPI0(12,13); 63 | DECLARE_SPI0(7,14); 64 | DECLARE_SPI0(8,14); 65 | DECLARE_SPI0(11,14); 66 | DECLARE_SPI0(12,14); 67 | DECLARE_SPI1(0,20); 68 | DECLARE_SPI1(1,20); 69 | DECLARE_SPI1(21,20); 70 | 71 | #elif defined(__SAM3X8E__) 72 | 73 | template 74 | class SPIOutput : public SAMHardwareSPIOutput {}; 75 | 76 | #elif defined(AVR_HARDWARE_SPI) 77 | 78 | template 79 | class SPIOutput : public AVRHardwareSPIOutput {}; 80 | 81 | #if defined(SPI_UART0_DATA) 82 | 83 | template 84 | class SPIOutput : public AVRUSART0SPIOutput {}; 85 | 86 | #endif 87 | 88 | #if defined(SPI_UART1_DATA) 89 | 90 | template 91 | class SPIOutput : public AVRUSART1SPIOutput {}; 92 | 93 | #endif 94 | 95 | #endif 96 | 97 | #else 98 | #warning "No hardware SPI pins defined. All SPI access will default to bitbanged output" 99 | 100 | #endif 101 | 102 | // #if defined(USART_DATA) && defined(USART_CLOCK) 103 | // template 104 | // class AVRSPIOutput : public AVRUSARTSPIOutput {}; 105 | // #endif 106 | 107 | #else 108 | #warning "Forcing software SPI - no hardware SPI for you!" 109 | #endif 110 | 111 | FASTLED_NAMESPACE_END 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/MMA7660.cpp: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | // Function: Cpp file for class MMC7660 3 | // Hardware: Grove - 3-Axis Digital Accelerometer(±1.5g) 4 | // Arduino IDE: Arduino-1.0 5 | // Author: Frankie.Chu 6 | // Date: Jan 10,2013 7 | // Version: v0.9b 8 | // by www.seeedstudio.com 9 | // 10 | // modify by loovee 11 | // 2013-9-25 12 | // add time out funtion in getXYZ 13 | // This library is free software; you can redistribute it and/or 14 | // modify it under the terms of the GNU Lesser General Public 15 | // License as published by the Free Software Foundation; either 16 | // version 2.1 of the License, or (at your option) any later version. 17 | // 18 | // This library is distributed in the hope that it will be useful, 19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | // Lesser General Public License for more details. 22 | // 23 | // You should have received a copy of the GNU Lesser General Public 24 | // License along with this library; if not, write to the Free Software 25 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | // 27 | /*******************************************************************************/ 28 | #include 29 | #include 30 | #include "MMA7660.h" 31 | /*Function: Write a byte to the register of the MMA7660*/ 32 | void MMA7660::write(uint8_t _register, uint8_t _data) 33 | { 34 | Wire.begin(); 35 | Wire.beginTransmission(MMA7660_ADDR); 36 | Wire.write(_register); 37 | Wire.write(_data); 38 | Wire.endTransmission(); 39 | } 40 | /*Function: Read a byte from the regitster of the MMA7660*/ 41 | uint8_t MMA7660::read(uint8_t _register) 42 | { 43 | uint8_t data_read; 44 | Wire.begin(); 45 | Wire.beginTransmission(MMA7660_ADDR); 46 | Wire.write(_register); 47 | Wire.endTransmission(); 48 | Wire.beginTransmission(MMA7660_ADDR); 49 | Wire.requestFrom(MMA7660_ADDR,1); 50 | while(Wire.available()) 51 | { 52 | data_read = Wire.read(); 53 | } 54 | Wire.endTransmission(); 55 | return data_read; 56 | } 57 | 58 | void MMA7660::init() 59 | { 60 | setMode(MMA7660_STAND_BY); 61 | setSampleRate(AUTO_SLEEP_120); 62 | setMode(MMA7660_ACTIVE); 63 | } 64 | 65 | void MMA7660::setMode(uint8_t mode) 66 | { 67 | write(MMA7660_MODE,mode); 68 | } 69 | void MMA7660::setSampleRate(uint8_t rate) 70 | { 71 | write(MMA7660_SR,rate); 72 | } 73 | /*Function: Get the contents of the registers in the MMA7660*/ 74 | /* so as to calculate the acceleration. */ 75 | unsigned char MMA7660::getXYZ(int8_t *x,int8_t *y,int8_t *z) 76 | { 77 | 78 | unsigned char val[3]; 79 | int count = 0; 80 | val[0] = val[1] = val[2] = 64; 81 | 82 | long timer1 = millis(); 83 | long timer2 = 0; 84 | 85 | while(Wire.available() > 0) 86 | { 87 | timer2 = millis(); 88 | if((timer2-timer1)>500) 89 | { 90 | return 0; 91 | } 92 | } 93 | 94 | Wire.read(); 95 | Wire.requestFrom(MMA7660_ADDR,3); 96 | 97 | timer1 = millis(); 98 | while(Wire.available()) 99 | { 100 | 101 | if(count < 3) 102 | { 103 | 104 | timer1 = millis(); 105 | while ( val[count] > 63 ) // reload the damn thing it is bad 106 | { 107 | val[count] = Wire.read(); 108 | 109 | timer2 = millis(); 110 | if((timer2-timer1)>50) 111 | { 112 | return 0; 113 | } 114 | 115 | } 116 | } 117 | 118 | count++; 119 | 120 | timer2 = millis(); 121 | 122 | if((timer2-timer1)>500) 123 | { 124 | return 0; 125 | } 126 | 127 | } 128 | 129 | *x = ((char)(val[0]<<2))/4; 130 | *y = ((char)(val[1]<<2))/4; 131 | *z = ((char)(val[2]<<2))/4; 132 | 133 | return 1; 134 | } 135 | 136 | unsigned char MMA7660::getAcceleration(float *ax,float *ay,float *az) 137 | { 138 | int8_t x,y,z; 139 | 140 | if(!getXYZ(&x, &y, &z))return 0; 141 | *ax = x/21.00; 142 | *ay = y/21.00; 143 | *az = z/21.00; 144 | 145 | return 1; 146 | 147 | } 148 | 149 | -------------------------------------------------------------------------------- /Firmware/Source/bakebit_v1.0.0/TM1637.h: -------------------------------------------------------------------------------- 1 | // Author: avishorp@gmail.com 2 | // 3 | // This library is free software; you can redistribute it and/or 4 | // modify it under the terms of the GNU Lesser General Public 5 | // License as published by the Free Software Foundation; either 6 | // version 2.1 of the License, or (at your option) any later version. 7 | // 8 | // This library is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | // Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with this library; if not, write to the Free Software 15 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 | 17 | #ifndef __TM1637__ 18 | #define __TM1637__ 19 | 20 | #include 21 | 22 | #define SEG_A 0b00000001 23 | #define SEG_B 0b00000010 24 | #define SEG_C 0b00000100 25 | #define SEG_D 0b00001000 26 | #define SEG_E 0b00010000 27 | #define SEG_F 0b00100000 28 | #define SEG_G 0b01000000 29 | 30 | class TM1637 { 31 | 32 | public: 33 | //! Initialize a TM1637 object, setting the clock and data pins. 34 | //! 35 | //! @param pinClk - The number of the digital pin connected to the clock pin of the module 36 | //! @param pinDIO - The number of the digital pin connected to the DIO pin of the module 37 | //TM1637(uint8_t pinClk, uint8_t pinDIO); 38 | void begin(uint8_t pinClk, uint8_t pinDIO); 39 | 40 | //! Sets the brightness of the display. 41 | //! 42 | //! The setting takes effect when a command is given to change the data being displayed. 43 | //! 44 | //! @param brightness A number from 0 (lowest brightness) to 7 (highest brightness) 45 | void setBrightness(uint8_t brightness); 46 | 47 | //! Display arbitrary data on the module 48 | //! 49 | //! This function receives raw segment values as input and displays them. The segment data 50 | //! is given as a byte array, each byte corresponding to a single digit. Within each byte, 51 | //! bit 0 is segment A, bit 1 is segment B etc. 52 | //! The function may either set the entire display or any desirable part on its own. The first 53 | //! digit is given by the @ref pos argument with 0 being the leftmost digit. The @ref length 54 | //! argument is the number of digits to be set. Other digits are not affected. 55 | //! 56 | //! @param segments An array of size @ref length containing the raw segment values 57 | //! @param length The number of digits to be modified 58 | //! @param pos The position from which to start the modification (0 - leftmost, 3 - rightmost) 59 | void setSegments(const uint8_t segments[], uint8_t length = 4, uint8_t pos = 0); 60 | 61 | //! Displays a decimal number 62 | //! 63 | //! Displays the given argument as a decimal number 64 | //! 65 | //! @param num The number to be shown 66 | //! @param leading_zero When true, leading zeros are displayed. Otherwise unnecessary digits are blank 67 | //! @param length The number of digits to set. The user must ensure that the number to be shown 68 | //! fits to the number of digits requested (for example, if two digits are to be displayed, 69 | //! the number must be between 0 to 99) 70 | //! @param pos The position least significant digit (0 - leftmost, 3 - rightmost) 71 | //! @param colon When true, displays two dots between the 2nd and 3rd segments 72 | void showNumberDec(int num, bool leading_zero = false, uint8_t length = 4, uint8_t pos = 0, bool colon = false); 73 | 74 | //! Translate a single digit into 7 segment code 75 | //! 76 | //! The method accepts a number between 0 - 15 and converts it to the 77 | //! code required to display the number on a 7 segment display. 78 | //! Numbers between 10-15 are converted to hexadecimal digits (A-F) 79 | //! 80 | //! @param digit A number between 0 to 15 81 | //! @return A code representing the 7 segment image of the digit (LSB - segment A; 82 | //! bit 6 - segment G; bit 7 - always zero) 83 | uint8_t encodeDigit(uint8_t digit); 84 | 85 | bool ready(); 86 | 87 | protected: 88 | void bitDelay(); 89 | void start(); 90 | void stop(); 91 | bool writeByte(uint8_t b); 92 | 93 | private: 94 | uint8_t m_pinClk; 95 | uint8_t m_pinDIO; 96 | uint8_t m_brightness; 97 | }; 98 | 99 | #endif // __TM1637__ 100 | --------------------------------------------------------------------------------