Am I2C-Bus des FTDI NerO haben wir auch unseren 433 MHz Funksender angeschlossen. Damit ist es möglich Funksteckdosen anzusteuern.
In dem Bild sind je zwei Buttons zum Ein- und Ausschalten der Steckdosen eingebaut.
//Variablen für Touchlogik + Farbwerte bool penDownOn30=false, penDownOn31=false, penDownOn32=false, penDownOn33=false; int32_t aOnButCol = BLUE, aOffButCol=GREY, bOnButCol = BLUE, bOffButCol=GREY ,aBackCol=LIGHTGREY,bBackCol = LIGHTGREY; void display_funk() { CleO.Start(); int tiefeBt1 = 100; CleO.StringExt(FONT_MEDIUM, 160, 0, BLUE, TM, 0, 0, „HOKA I2C DEMO“); CleO.RectangleExt(0, 50, 350, 500, WHITE, TL, 0, 0); CleO.LineWidth(30); if (penDownOnBack) { penDownOnBack = false; globalCurrSite = 0; } else if (penDownOn30) { penDownOn30 = false; send433Data(1,129); aBackCol = GREEN; aOnButCol = GREY; aOffButCol = BLUE; } else if (penDownOn31) { penDownOn31 = false; send433Data(1,130); bBackCol = GREEN; bOnButCol = GREY; bOffButCol = BLUE; } else if (penDownOn32) { penDownOn32 = false; send433Data(1,1); aBackCol = RED; aOnButCol = BLUE; aOffButCol = GREY; } else if (penDownOn33) { penDownOn33 = false; send433Data(1,2); bBackCol = RED; bOnButCol = BLUE; bOffButCol = GREY; } //Hintergrund A CleO.RectangleExt(20, 60, 280, 125, aBackCol, TL, 0, 0); //Hintergrund B CleO.RectangleExt(20, 200, 280, 125, bBackCol, TL, 0, 0); //Gruppe A CleO.Tag(30); CleO.RectangleExt(30, 80, 100, 65, aOnButCol, TL, 0, 0); CleO.StringExt(FONT_MEDIUM,80, 110, WHITE, MM, 0, 0, „A EIN“); CleO.Tag(32); CleO.RectangleExt(180, 80, 100, 65, aOffButCol, TL, 0, 0); CleO.StringExt(FONT_MEDIUM,230, 110, WHITE, MM, 0, 0, „A AUS“); //Gruppe B CleO.Tag(31); CleO.RectangleExt(30, 220, 100, 65, bOnButCol, TL, 0, 0); CleO.StringExt(FONT_MEDIUM,80, 250, WHITE, MM, 0, 0, „B EIN“); CleO.Tag(33); CleO.RectangleExt(180, 220, 100, 65, bOffButCol, TL, 0, 0); CleO.StringExt(FONT_MEDIUM,230, 250, WHITE, MM, 0, 0, „B AUS“); CleO.Tag(100); CleO.LineColor(BLUE); CleO.Line(0, 375, 350, 375); CleO.StringExt(FONT_MEDIUM,160, 375, WHITE, MM, 0, 0, „Startseite“); CleO.StringExt(FONT_SANS_2, 160, 440, BLUE, TM, 0, 0, „www.horter.de“); CleO.Show(); } void control_funk() { int16_t x, y, dur, tag; CleO.TouchCoordinates(x, y, dur, tag); if (previousDur == 0 && dur != 0) { previousTag = tag; previousDur = 1; if (tag == 100) penDownOnBack = true; else if (tag == 30) penDownOn30 = true; else if (tag == 31) penDownOn31 = true; else if (tag == 32) penDownOn32 = true; else if (tag == 33) penDownOn33 = true; } else if (previousDur == 1 && dur == 0) { previousDur = 0; if (previousTag == 100) penDownOnBack = false; else if (previousTag == 30) penDownOn30 = false; else if (previousTag == 31) penDownOn31 = false; else if (previousTag == 32) penDownOn32 = false; else if (previousTag == 33) penDownOn33 = false; } } void send433Data(int fb, int sb) //Erstes und zweites Bit { int wdh = 2; for (int i=0;i<wdh;i++) { Wire.beginTransmission(I2C_433MHz_ADDR); Wire.write(fb); Wire.write(sb); Wire.endTransmission(); } }