-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHL2_I2C.ino
More file actions
72 lines (56 loc) · 2.19 KB
/
Copy pathHL2_I2C.ino
File metadata and controls
72 lines (56 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//***************************************************************************************
//*
//* *
//* Based on HL2-PA70 by Cesc Gudayol (EA3IGT) Version 3.0.1 from 01/04/2021 *
//* More info: https://github.com/ea3igt/HL2-PA70 *
//* * *
//* *
//***************************************************************************************
//* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND *
//***************************************************************************************
#include <Wire.h> //For I2C control
#include <EEPROM.h> //To store values from PA70-Controller
#include <util/delay.h> //Library to delay inside one Interrupt
void setup() {
Serial.begin(9600);
// I2C Slave Setup
Wire.begin(0x20); // join i2c bus with address to listen
Wire.onReceive(receiveEvent); // register event
delay(200);
}
// Main loop program
void loop()
{
void receiveEvent(int howMany) { //Triggered when receive I2C information from HL2
byte c[10];
int i= 0;
while (0 < Wire.available()) { // loop through all but the last
c[i] = Wire.read(); // receive byte as a character
i++;
}
byte myC=c[1] & B00111111; //Get 6 least significative bits
decodeBand(myC); //Decode Band
}
void decodeBand(byte c)
{
switch (c) {
case 0x1: //160m
Serial.println("160M;");
break;
case 0x2: //80m
Serial.println("80M;");
break;
case 0x4: //40m
Serial.println("40M;");
break;
case 0x8: //30m & 20m
Serial.println("20M;");
break;
case 0x10: //17m & 15m
Serial.println("15M;");
break;
case 0x20: //12m & 10m
Serial.println("10M;");
break;
}
}