First commit
This commit is contained in:
@@ -0,0 +1,192 @@
|
||||
/**<
|
||||
|
||||
this is untidy and not very intuitive BUT it works so far
|
||||
the code was not refactored once... maybe i have time for this in the future
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "WS2812B.h"
|
||||
WS2812B ws2812b;
|
||||
|
||||
#define LEDS_SIZE 90 //120
|
||||
#define LEDS_CHANNELS 3
|
||||
#define LEDS_DELAY 55
|
||||
#define LEDS_DIST 30 //(LEDS_SIZE/LEDS_CHANNELS)
|
||||
#define LEDS_INCR 1 //12 //(255/(LEDS_SIZE/LEDS_CHANNELS))
|
||||
#define LEDS_MAX LEDS_INCR*LEDS_DIST
|
||||
struct cRGB led[LEDS_SIZE]; // cGRB
|
||||
|
||||
volatile uint8_t selected_led, actual_led, actual_channel, actual_status;
|
||||
|
||||
struct time {
|
||||
uint8_t tv_hour;
|
||||
uint8_t tv_min;
|
||||
uint8_t tv_sec;
|
||||
uint16_t tv_msec;
|
||||
} clock;
|
||||
|
||||
struct timeA {
|
||||
uint16_t tv_hour;
|
||||
uint16_t tv_min;
|
||||
uint16_t tv_sec;
|
||||
} analog;
|
||||
|
||||
#define SCALEMAX 12000
|
||||
|
||||
#define SCALEHA (SCALEMAX / 24) // 500
|
||||
#define SCALEHB (SCALEHA / 60) // 8.33
|
||||
#define SCALEMA (SCALEMAX / 60)
|
||||
#define SCALEMB (SCALEMA / 60)
|
||||
#define SCALESA (SCALEMAX / 60) // 200
|
||||
#define SCALESB (SCALESA / 1000) // 0.2
|
||||
#define SCALESBi (1000 / SCALESA) // 5
|
||||
#define SCALELED (SCALEMAX / LEDS_SIZE)
|
||||
|
||||
uint32_t milli_old;
|
||||
|
||||
void get_analog() {
|
||||
uint32_t milli_new = millis();
|
||||
uint32_t tv_msec = clock.tv_msec + (milli_new - milli_old);
|
||||
milli_old = milli_new;
|
||||
uint32_t tv_sec = clock.tv_sec + (tv_msec/1000);
|
||||
uint32_t tv_min = clock.tv_min + (tv_sec / 60);
|
||||
uint32_t tv_hour = clock.tv_hour + (tv_min / 60);
|
||||
/*
|
||||
uint8_t tv_day = (tv_hour / 24);
|
||||
clock.tv_hour = tv_hour - tv_day * 24;
|
||||
clock.tv_min = tv_min - tv_hour* 60;
|
||||
clock.tv_sec = tv_sec - tv_min * 60;
|
||||
clock.tv_msec = tv_msec - tv_sec * 1000;
|
||||
*/
|
||||
while (tv_hour > 23) tv_hour -= 24;
|
||||
clock.tv_hour = tv_hour;
|
||||
while (tv_min > 59) tv_min -= 60;
|
||||
clock.tv_min = tv_min;
|
||||
while (tv_sec > 59) tv_sec -= 60;
|
||||
clock.tv_sec = tv_sec;
|
||||
while (tv_msec > 999) tv_msec -= 1000;
|
||||
clock.tv_msec = tv_msec;
|
||||
|
||||
|
||||
// zahlen normiert
|
||||
analog.tv_hour = (clock.tv_hour*SCALEHA) + (clock.tv_min*SCALEHB);
|
||||
if (analog.tv_hour >= SCALEMAX) analog.tv_hour -= SCALEMAX;
|
||||
analog.tv_min = (clock.tv_min*SCALEMA) + (clock.tv_sec*SCALEMB);
|
||||
if (analog.tv_min >= SCALEMAX) analog.tv_min -= SCALEMAX;
|
||||
analog.tv_sec = (clock.tv_sec*SCALESA) + (clock.tv_msec/SCALESBi);
|
||||
if (analog.tv_sec >= SCALEMAX) analog.tv_sec -= SCALEMAX;
|
||||
}
|
||||
|
||||
|
||||
void setup(void) {
|
||||
clock.tv_hour = 3;
|
||||
clock.tv_min = 45;
|
||||
clock.tv_sec = 50;
|
||||
clock.tv_msec = 0;
|
||||
}
|
||||
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
|
||||
uint8_t red, green, blue;
|
||||
uint8_t ledi;
|
||||
|
||||
red = LEDS_MAX;
|
||||
green = 0;
|
||||
blue = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
// Farbkreis - Algo
|
||||
ledi = actual_led;
|
||||
for (uint8_t x=0; x<LEDS_SIZE; x++) {
|
||||
|
||||
if (x < LEDS_DIST) { blue = 0; red = red - LEDS_INCR; green = green + LEDS_INCR; }
|
||||
else if (x < 2*LEDS_DIST) { red = 0; green = green - LEDS_INCR; blue = blue + LEDS_INCR; }
|
||||
else { green = 0; blue = blue - LEDS_INCR; red = red + LEDS_INCR; }
|
||||
|
||||
#define GROUNDLIGHT 0
|
||||
#define SHIFTFACTOR 0
|
||||
led[ledi].r = GROUNDLIGHT + (red>>SHIFTFACTOR);
|
||||
led[ledi].g = GROUNDLIGHT + (green>>SHIFTFACTOR);
|
||||
led[ledi].b = GROUNDLIGHT + (blue>>SHIFTFACTOR);
|
||||
|
||||
if (++ledi >= LEDS_SIZE) ledi = 0;
|
||||
}
|
||||
//if (++actual_led>=LEDS_SIZE) { actual_led = 0; } // Clockwise Color-Ring
|
||||
if (actual_led--==0) actual_led = LEDS_SIZE - 1; // Reverse Color-Ring
|
||||
|
||||
// Uhr einfügen
|
||||
#define CLOCK_INTENSITY 255
|
||||
#define CLOCK_WIDTH (1)
|
||||
|
||||
uint8_t led_mid, led_sel, led_overflow;
|
||||
int16_t value;
|
||||
uint16_t analog_LED;
|
||||
|
||||
get_analog();
|
||||
|
||||
//if (led[analog.tv_hour/SCALELED].r < CLOCK_INTENSITY) { led[analog.tv_hour/SCALELED].r = CLOCK_INTENSITY; }
|
||||
//if (led[analog.tv_min/SCALELED].g < CLOCK_INTENSITY) { led[analog.tv_min/SCALELED].g = CLOCK_INTENSITY; }
|
||||
|
||||
// HOURS
|
||||
led_mid = (analog.tv_hour/SCALELED);
|
||||
led_overflow = 0;
|
||||
if (led_mid >= CLOCK_WIDTH) { led_sel = led_mid - CLOCK_WIDTH; }
|
||||
|
||||
else { led_sel = led_mid + (LEDS_SIZE - CLOCK_WIDTH); analog.tv_hour += SCALEMAX; }
|
||||
for (uint8_t x=0; x<=2*CLOCK_WIDTH; x++) {
|
||||
if (led_overflow) { analog_LED = (led_sel + LEDS_SIZE) * SCALELED; }
|
||||
else { analog_LED = led_sel * SCALELED; }
|
||||
if (analog_LED > analog.tv_hour) { value = (analog_LED - analog.tv_hour); }
|
||||
else { value = (analog.tv_hour - analog_LED); }
|
||||
if (value > CLOCK_INTENSITY) { value = 0; }
|
||||
else { value = CLOCK_INTENSITY - value; }
|
||||
if (led[led_sel].r < value) { led[led_sel].r = value; } // intensity normal
|
||||
if (++led_sel >= LEDS_SIZE) { led_sel -= LEDS_SIZE; led_overflow = 1;}
|
||||
}
|
||||
|
||||
// MINUTES
|
||||
led_mid = (analog.tv_min/SCALELED);
|
||||
led_overflow = 0;
|
||||
if (led_mid >= CLOCK_WIDTH) { led_sel = led_mid - CLOCK_WIDTH; }
|
||||
else { led_sel = led_mid + (LEDS_SIZE - CLOCK_WIDTH); analog.tv_min += SCALEMAX; }
|
||||
|
||||
for (uint8_t x=0; x<=2*CLOCK_WIDTH; x++) {
|
||||
if (led_overflow) { analog_LED = (led_sel + LEDS_SIZE) * SCALELED; }
|
||||
else { analog_LED = led_sel * SCALELED; }
|
||||
if (analog_LED > analog.tv_min) { value = (analog_LED - analog.tv_min); }
|
||||
else { value = (analog.tv_min - analog_LED); }
|
||||
if (value > CLOCK_INTENSITY) { value = 0; }
|
||||
else { value = CLOCK_INTENSITY - value; }
|
||||
if (led[led_sel].g < value) { led[led_sel].g = value; } // intensity normal
|
||||
if (++led_sel >= LEDS_SIZE) { led_sel -= LEDS_SIZE; led_overflow = 1;}
|
||||
}
|
||||
|
||||
// SECONDS
|
||||
led_mid = (analog.tv_sec/SCALELED);
|
||||
led_overflow = 0;
|
||||
if (led_mid >= CLOCK_WIDTH) { led_sel = led_mid - CLOCK_WIDTH; }
|
||||
else { led_sel = led_mid + (LEDS_SIZE - CLOCK_WIDTH); analog.tv_sec += SCALEMAX; }
|
||||
|
||||
for (uint8_t x=0; x<=2*CLOCK_WIDTH; x++) {
|
||||
if (led_overflow) { analog_LED = (led_sel + LEDS_SIZE) * SCALELED; }
|
||||
else { analog_LED = led_sel * SCALELED; }
|
||||
if (analog_LED > analog.tv_sec) { value = (analog_LED - analog.tv_sec); }
|
||||
else { value = (analog.tv_sec - analog_LED); }
|
||||
if (value > CLOCK_INTENSITY) { value = 0; }
|
||||
else { value = CLOCK_INTENSITY - value; }
|
||||
if (led[led_sel].b < value) { led[led_sel].b = value; } // intensity normal
|
||||
if (++led_sel >= LEDS_SIZE) { led_sel -= LEDS_SIZE; led_overflow = 1;}
|
||||
}
|
||||
|
||||
|
||||
//led[0].r=255;led[0].g=0;led[0].b=0; // Write red to array
|
||||
ws2812b.setleds(led,LEDS_SIZE);
|
||||
_delay_ms(LEDS_DELAY); // wait for 500ms.
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,102 @@
|
||||
|
||||
#include <math.h>
|
||||
//#include <JeeLib.h>
|
||||
|
||||
|
||||
#include <atmel_eFunction.h>
|
||||
eFunction eFkt;
|
||||
|
||||
#define PWR 1.6
|
||||
#define MAX_X 1024
|
||||
#define STDVALUE 512
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
eFkt.init(STDVALUE, MAX_X, MAX_X,PWR);
|
||||
|
||||
Serial.println("Test Function PowerOf and Scale: ");
|
||||
Serial.println(" X, Y_orig, Y_new");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
uint32_t time_start, duration_original, duration_new, result_original, result_new, result_error;
|
||||
float scale, max_y, max_x;
|
||||
|
||||
max_x = MAX_X-STDVALUE;
|
||||
max_y = pow(max_x, PWR); //interval^(1/1.7)
|
||||
scale = max_x / max_y;
|
||||
|
||||
result_error = 0;
|
||||
|
||||
for (uint16_t ivar = 0; ivar < 1034; ivar++)
|
||||
{
|
||||
if (ivar >= STDVALUE) result_original = pow(ivar - STDVALUE, PWR)*scale + STDVALUE;
|
||||
else result_original = STDVALUE - pow(STDVALUE - ivar, PWR)*scale;
|
||||
|
||||
result_new = eFkt.get(ivar);
|
||||
|
||||
if (result_new > result_original) result_error += result_new - result_original;
|
||||
else result_error += result_original - result_new;
|
||||
|
||||
Serial.print(" ");
|
||||
Serial.print(ivar);
|
||||
Serial.print(", ");
|
||||
Serial.print(result_original);
|
||||
Serial.print(", ");
|
||||
Serial.print(result_new);
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
result_original = 0;
|
||||
result_new = 0;
|
||||
|
||||
time_start = micros();
|
||||
for (uint16_t ivar = 0; ivar < 1024; ivar++)
|
||||
{
|
||||
if (ivar >= STDVALUE) result_original += pow(ivar - STDVALUE, PWR)*scale + STDVALUE;
|
||||
else result_original += STDVALUE - pow(STDVALUE - ivar, PWR)*scale;
|
||||
}
|
||||
duration_original = micros() - time_start;
|
||||
|
||||
time_start = micros();
|
||||
for (uint16_t ivar = 0; ivar < 1024; ivar++)
|
||||
{
|
||||
result_new += eFkt.get(ivar);
|
||||
}
|
||||
duration_new = micros() - time_start;
|
||||
|
||||
Serial.print("Result_sum : ");
|
||||
Serial.print(result_original);
|
||||
Serial.print(", ");
|
||||
Serial.print(result_new);
|
||||
Serial.println("");
|
||||
|
||||
Serial.print("Calculation_time_sum us : ");
|
||||
Serial.print(duration_original);
|
||||
Serial.print(", ");
|
||||
Serial.print(duration_new);
|
||||
Serial.println("");
|
||||
|
||||
Serial.print("Error/Mean : ");
|
||||
Serial.print(result_error / 1024.0);
|
||||
Serial.println("");
|
||||
|
||||
while(1)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5:
|
||||
A1.5.7:
|
||||
|
||||
*/
|
||||
|
@@ -0,0 +1,36 @@
|
||||
/**<
|
||||
|
||||
Program Fuses:
|
||||
|
||||
EXT 0xFD
|
||||
HIGH 0xDF or xDE (bootrst EN)
|
||||
LOW 0xFF
|
||||
|
||||
*/
|
||||
|
||||
#define TIMEON 20
|
||||
#define TIMEOFF (1000-TIMEON)
|
||||
|
||||
#define LEDPINA 8
|
||||
#define LEDPINB 11
|
||||
|
||||
void setup() {
|
||||
pinMode(LEDPINA, OUTPUT);
|
||||
pinMode(LEDPINB, OUTPUT);
|
||||
digitalWrite(LEDPINA,LOW);
|
||||
digitalWrite(LEDPINB,LOW);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
delay(TIMEOFF);
|
||||
digitalWrite(LEDPINA,HIGH);
|
||||
digitalWrite(LEDPINB,HIGH);
|
||||
delay(TIMEON); // busywaiting
|
||||
digitalWrite(LEDPINA,LOW);
|
||||
digitalWrite(LEDPINB,LOW);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,59 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
#include "i2c_BMP280.h"
|
||||
BMP280 bmp280;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Probe BMP280: ");
|
||||
if (bmp280.initialize()) Serial.println("Sensor found");
|
||||
else
|
||||
{
|
||||
Serial.println("Sensor missing");
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
// onetime-measure:
|
||||
bmp280.setEnabled(0);
|
||||
bmp280.triggerMeasurement();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
bmp280.awaitMeasurement();
|
||||
|
||||
float temperature;
|
||||
bmp280.getTemperature(temperature);
|
||||
|
||||
float pascal;
|
||||
bmp280.getPressure(pascal);
|
||||
|
||||
static float meters, metersold;
|
||||
bmp280.getAltitude(meters);
|
||||
metersold = (metersold * 10 + meters)/11;
|
||||
|
||||
bmp280.triggerMeasurement();
|
||||
|
||||
Serial.print(" HeightPT1: ");
|
||||
Serial.print(metersold);
|
||||
Serial.print(" m; Height: ");
|
||||
Serial.print(meters);
|
||||
Serial.print(" Pressure: ");
|
||||
Serial.print(pascal);
|
||||
Serial.print(" Pa; T: ");
|
||||
Serial.print(temperature);
|
||||
Serial.println(" C");
|
||||
}
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5:
|
||||
A1.5.7: 9680b
|
||||
A1.6.3: 9664b / 561b
|
||||
|
||||
*/
|
||||
|
44
firmware/I2C-Sensor-Lib_iLib/examples/i2c_L3G/i2c_L3G.ino
Normal file
44
firmware/I2C-Sensor-Lib_iLib/examples/i2c_L3G/i2c_L3G.ino
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
#include "i2c_L3G.h"
|
||||
L3G l3g;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Probe L3G: ");
|
||||
if (l3g.initialize()) Serial.println("Sensor found!");
|
||||
else
|
||||
{
|
||||
Serial.println("Sensor missing");
|
||||
while(1) {};
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
float xyz_dps[3];
|
||||
|
||||
l3g.getMeasurement(xyz_dps);
|
||||
|
||||
Serial.print(" X: ");
|
||||
Serial.print(xyz_dps[0],2);
|
||||
Serial.print(" \tY: ");
|
||||
Serial.print(xyz_dps[1],2);
|
||||
Serial.print(" \tZ: ");
|
||||
Serial.print(xyz_dps[2],2);
|
||||
Serial.println("");
|
||||
delay(20);
|
||||
|
||||
}
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5:
|
||||
A1.5.7: 7226b
|
||||
A1.6.3: 7160b / 483b
|
||||
*/
|
@@ -0,0 +1,53 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
// Pressure-Sensor
|
||||
#include "i2c_LPS331.h"
|
||||
LPS331 lps331;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Probe LPS331: ");
|
||||
if (lps331.initialize()) Serial.println("Sensor found!");
|
||||
else
|
||||
{
|
||||
Serial.println("Sensor missing");
|
||||
while(1) {};
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
static float mbar, degC;
|
||||
|
||||
Serial.print("Altitude: ");
|
||||
//static int32_t cm;
|
||||
//lps331.getAltitude(cm);
|
||||
//Serial.print(cm);
|
||||
static float meter;
|
||||
lps331.getAltitude(meter);
|
||||
Serial.print(meter);
|
||||
|
||||
//lps331.getMeasurement(mbar);
|
||||
//Serial.print("Pressure: ");
|
||||
//Serial.print(mbar);
|
||||
|
||||
lps331.getTemperature(degC);
|
||||
Serial.print(" \tTemperature: ");
|
||||
Serial.print(degC);
|
||||
Serial.println("");
|
||||
|
||||
delay(20);
|
||||
}
|
||||
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5: 7098b
|
||||
A1.5.7:
|
||||
A1.6.3: 7184b / 567b
|
||||
*/
|
@@ -0,0 +1,44 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
#include "i2c_MAG3110.h"
|
||||
MAG3110 mag3110;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Probe MAG3310: ");
|
||||
if (mag3110.initialize()) Serial.println("Sensor found!");
|
||||
else
|
||||
{
|
||||
Serial.println("Sensor missing");
|
||||
while(1) {};
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
float xyz_uT[3];
|
||||
|
||||
mag3110.getMeasurement(xyz_uT);
|
||||
|
||||
Serial.print(" X: ");
|
||||
Serial.print(xyz_uT[0],2);
|
||||
Serial.print(" \tY: ");
|
||||
Serial.print(xyz_uT[1],2);
|
||||
Serial.print(" \tZ: ");
|
||||
Serial.print(xyz_uT[2],2);
|
||||
Serial.println("");
|
||||
delay(20);
|
||||
|
||||
}
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5: 7144b
|
||||
A1.5.7: 6860b
|
||||
A1.6.3: 6766b / 493b
|
||||
*/
|
@@ -0,0 +1,39 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
#include "i2c_MAX44009.h"
|
||||
MAX44009 max44009;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.println("Probe MAX44009: ");
|
||||
if (max44009.initialize()) Serial.println("Sensor found");
|
||||
else
|
||||
{
|
||||
Serial.println("Sensor missing");
|
||||
while (1) { };
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
static unsigned long mLux_value;
|
||||
|
||||
max44009.getMeasurement(mLux_value);
|
||||
|
||||
Serial.print("mLUX: ");
|
||||
Serial.print(mLux_value);
|
||||
Serial.println(" ");
|
||||
|
||||
delay(40);
|
||||
}
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5: 5126b
|
||||
A1.5.7: 4860b
|
||||
A1.6.3: 4764b / 463b
|
||||
*/
|
@@ -0,0 +1,45 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
#include "i2c_MMA8451.h"
|
||||
MMA8451 mma8451;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Probe MMA8451: ");
|
||||
if (mma8451.initialize()) Serial.println("Sensor found!");
|
||||
else
|
||||
{
|
||||
Serial.println("Sensor missing");
|
||||
while(1) {};
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
static float xyz_g[3];
|
||||
|
||||
mma8451.getMeasurement(xyz_g);
|
||||
|
||||
Serial.print(" X: ");
|
||||
Serial.print(xyz_g[0],2);
|
||||
Serial.print(" \tY: ");
|
||||
Serial.print(xyz_g[1],2);
|
||||
Serial.print(" \tZ: ");
|
||||
Serial.print(xyz_g[2],2);
|
||||
Serial.println("");
|
||||
delay(20);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5:
|
||||
A1.5.7: 6992b
|
||||
A1.6.3: 6988b / 494b
|
||||
*/
|
@@ -0,0 +1,49 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
#include "i2c_MPL3115A2.h"
|
||||
MPL3115A2 mpl3115;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Probe MPL3115A2: ");
|
||||
if (mpl3115.initialize()) Serial.println("Sensor found");
|
||||
else
|
||||
{
|
||||
Serial.println("Sensor missing");
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
// onetime-measure:
|
||||
mpl3115.setEnabled(0);
|
||||
mpl3115.triggerMeasurement();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
mpl3115.awaitMeasurement();
|
||||
|
||||
float altitude;
|
||||
mpl3115.getAltitude(altitude);
|
||||
|
||||
float temperature;
|
||||
mpl3115.getTemperature(temperature);
|
||||
mpl3115.triggerMeasurement();
|
||||
|
||||
Serial.print(" Height: ");
|
||||
Serial.print(altitude);
|
||||
Serial.print(" Temp: ");
|
||||
Serial.print(temperature);
|
||||
Serial.println("");
|
||||
}
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5:
|
||||
A1.5.7: 6980b
|
||||
A1.6.3: 6890b / 495b
|
||||
*/
|
||||
|
@@ -0,0 +1,63 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
// IMU-Sensor
|
||||
#include "i2c_MPU9250.h"
|
||||
MPU9250 mpu9250;
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Probe MPU9250: ");
|
||||
switch (mpu9250.initialize())
|
||||
{
|
||||
case 0: Serial.println("MPU-Sensor missing"); while(1) {};
|
||||
case 1: Serial.println("Found unknown Sensor."); break;
|
||||
case 2: Serial.println("MPU6500 found."); break;
|
||||
case 3: Serial.println("MPU9250 found!"); break;
|
||||
}
|
||||
|
||||
Serial.print("Probe AK8963: ");
|
||||
if (i2c.probe(0x0C)) Serial.println("AK8963 found!");
|
||||
else Serial.println("AK8963 missing");
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
static float xyz_GyrAccMag[9];
|
||||
|
||||
mpu9250.getMeasurement(xyz_GyrAccMag);
|
||||
|
||||
Serial.print("XYZ ACC g[");
|
||||
Serial.print(xyz_GyrAccMag[0],2);
|
||||
Serial.print(";");
|
||||
Serial.print(xyz_GyrAccMag[1],2);
|
||||
Serial.print(";");
|
||||
Serial.print(xyz_GyrAccMag[2],2);
|
||||
Serial.print("]");
|
||||
|
||||
Serial.print(" \t GYR dps[");
|
||||
Serial.print(xyz_GyrAccMag[4],2);
|
||||
Serial.print(";");
|
||||
Serial.print(xyz_GyrAccMag[5],2);
|
||||
Serial.print(";");
|
||||
Serial.print(xyz_GyrAccMag[6],2);
|
||||
Serial.print("]");
|
||||
|
||||
Serial.print(" \t T: ");
|
||||
Serial.print(xyz_GyrAccMag[3],2);
|
||||
Serial.print(" C");
|
||||
|
||||
Serial.println("");
|
||||
delay(20);
|
||||
}
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5:
|
||||
A1.5.7:
|
||||
A1.6.3: 7752b / 631b
|
||||
*/
|
@@ -0,0 +1,63 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
// RTC
|
||||
#include "i2c_PCF2127.h"
|
||||
PCF2127 pcf2127;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Probe PCF2127: ");
|
||||
if (pcf2127.initialize()) Serial.println("Module found");
|
||||
else
|
||||
{
|
||||
Serial.println("Module missing");
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
pcf2127.setTime(2014,9,3,5,4,11,12);
|
||||
char time = '__TIME__';
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
uint8_t MM,WW,DD,hh,mm,ss;
|
||||
uint16_t YY;
|
||||
pcf2127.readTime();
|
||||
|
||||
pcf2127.getYears(YY);
|
||||
pcf2127.getMonth(MM);
|
||||
pcf2127.getWeekdays(WW);
|
||||
pcf2127.getDays(DD);
|
||||
pcf2127.getHours(hh);
|
||||
pcf2127.getMinutes(mm);
|
||||
pcf2127.getSeconds(ss);
|
||||
|
||||
Serial.print(YY);
|
||||
Serial.print("-");
|
||||
Serial.print(MM);
|
||||
Serial.print("-");
|
||||
Serial.print(WW);
|
||||
Serial.print("-");
|
||||
Serial.print(DD);
|
||||
Serial.print(" ");
|
||||
|
||||
Serial.print(hh);
|
||||
Serial.print(":");
|
||||
Serial.print(mm);
|
||||
Serial.print(":");
|
||||
Serial.print(ss);
|
||||
Serial.println("");
|
||||
delay(200);
|
||||
}
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5: 6754b
|
||||
A1.5.7: 6454b
|
||||
A1.6.3: 5016b / 446b
|
||||
*/
|
@@ -0,0 +1,43 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
#include "i2c_SI7021.h"
|
||||
SI7021 si7021;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Probe SI7021: ");
|
||||
if (si7021.initialize()) Serial.println("Sensor found!");
|
||||
else
|
||||
{
|
||||
Serial.println("Sensor missing");
|
||||
while(1) {};
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
static float humi, temp;
|
||||
|
||||
si7021.getHumidity(humi);
|
||||
si7021.getTemperature(temp);
|
||||
si7021.triggerMeasurement();
|
||||
|
||||
Serial.print("TEMP: ");
|
||||
Serial.print(temp);
|
||||
Serial.print(" HUMI: ");
|
||||
Serial.print(humi);
|
||||
Serial.println("");
|
||||
|
||||
}
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5: 6896b
|
||||
A1.5.7: 6590b
|
||||
A1.6.3: 6484b / 499b
|
||||
*/
|
@@ -0,0 +1,53 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
#include "i2c_TCS3772.h"
|
||||
TCS3772 tcs3772;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Probe TCS3772: ");
|
||||
if (tcs3772.initialize()) Serial.println("Sensor found");
|
||||
else
|
||||
{
|
||||
Serial.println("Sensor missing");
|
||||
while (1) {}
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
static uint16_t value_crgb[4], scale_factor;
|
||||
|
||||
tcs3772.getMeasurement(value_crgb);
|
||||
|
||||
scale_factor = tcs3772.autoGain(value_crgb[0]);
|
||||
|
||||
if (scale_factor)
|
||||
{
|
||||
Serial.print(" R: ");
|
||||
Serial.print(value_crgb[1]);
|
||||
Serial.print(" G: ");
|
||||
Serial.print(value_crgb[2]);
|
||||
Serial.print(" B: ");
|
||||
Serial.print(value_crgb[3]);
|
||||
Serial.print(" C: ");
|
||||
Serial.print(value_crgb[0]);
|
||||
Serial.print(" GAIN: ");
|
||||
Serial.print(scale_factor);
|
||||
Serial.println("");
|
||||
}
|
||||
delay(50);
|
||||
}
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5: 6754b
|
||||
A1.5.7: 6454b
|
||||
A1.6.3: 6322b / 494b
|
||||
*/
|
@@ -0,0 +1,37 @@
|
||||
#include <Wire.h>
|
||||
#include "i2c.h"
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("Scan I2C-Bus for responses");
|
||||
|
||||
uint8_t address, result;
|
||||
|
||||
for(address = 0; address < 128; address++ )
|
||||
{
|
||||
result = i2c.probe(address);
|
||||
|
||||
if (result)
|
||||
{
|
||||
Serial.print("Found: 0x");
|
||||
if (address < 17) Serial.print("0");
|
||||
Serial.print(address,HEX);
|
||||
Serial.println("");
|
||||
}
|
||||
delay(20);
|
||||
}
|
||||
Serial.println("");
|
||||
Serial.println("DONE");
|
||||
}
|
||||
|
||||
void loop() { }
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A1.0.5:
|
||||
A1.5.7: 4072b
|
||||
A1.6.3: 3982b / 435b
|
||||
|
||||
*/
|
@@ -0,0 +1,54 @@
|
||||
#include <SPI.h>
|
||||
#include "spi_rfm95.h"
|
||||
RFM95 rfm;
|
||||
|
||||
|
||||
#define TIMEON 20
|
||||
#define TIMEOFF (1000-TIMEON)
|
||||
#define LEDPINA 8
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.println(rfm.getFrequency());
|
||||
Serial.print("Probe RFM95W: ");
|
||||
if (rfm.initialize()) Serial.println("missing");
|
||||
else
|
||||
{
|
||||
Serial.println("found");
|
||||
while(1) {};
|
||||
}
|
||||
|
||||
Serial.println(rfm.getFrequency());
|
||||
rfm.receiveDataCont();
|
||||
|
||||
//while (1) { rfm.handleIRQ(); };
|
||||
|
||||
pinMode(LEDPINA, OUTPUT);
|
||||
digitalWrite(LEDPINA,HIGH);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
rfm.handleIRQ();
|
||||
delay(TIMEOFF);
|
||||
if (rfm.canSend())
|
||||
{
|
||||
digitalWrite(LEDPINA,HIGH);
|
||||
rfm.sendData();
|
||||
};
|
||||
|
||||
delay(TIMEON);
|
||||
digitalWrite(LEDPINA,LOW);
|
||||
}
|
||||
|
||||
/**<
|
||||
|
||||
Program size:
|
||||
A105: b
|
||||
A157: b
|
||||
|
||||
*/
|
||||
|
Reference in New Issue
Block a user