Skip to content

Commit f49ef59

Browse files
committed
update register address to match new map
-removed a lot of unneeded stuff from button firmware
1 parent 299d66c commit f49ef59

File tree

2 files changed

+2
-173
lines changed

2 files changed

+2
-173
lines changed

src/SparkFun_Qwiic_Buzzer_Arduino_Library.cpp

Lines changed: 1 addition & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -102,172 +102,13 @@ uint8_t QwiicBuzzer::getI2Caddress()
102102
return _deviceAddress;
103103
}
104104

105-
/*------------------------------ Button Status ---------------------- */
106-
bool QwiicBuzzer::isPressed()
107-
{
108-
statusRegisterBitField statusRegister;
109-
statusRegister.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_BUTTON_STATUS);
110-
return statusRegister.isPressed;
111-
}
112-
113-
bool QwiicBuzzer::hasBeenClicked()
114-
{
115-
statusRegisterBitField statusRegister;
116-
statusRegister.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_BUTTON_STATUS);
117-
return statusRegister.hasBeenClicked;
118-
}
119-
120-
uint16_t QwiicBuzzer::getDebounceTime()
121-
{
122-
return readDoubleRegister(SFE_QWIIC_BUTTON_BUTTON_DEBOUNCE_TIME);
123-
}
124-
125-
uint8_t QwiicBuzzer::setDebounceTime(uint16_t time)
126-
{
127-
return writeDoubleRegisterWithReadback(SFE_QWIIC_BUTTON_BUTTON_DEBOUNCE_TIME, time);
128-
}
129-
130-
/*------------------- Interrupt Status/Configuration ---------------- */
131-
uint8_t QwiicBuzzer::enablePressedInterrupt()
132-
{
133-
interruptConfigBitField interruptConfigure;
134-
interruptConfigure.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_INTERRUPT_CONFIG);
135-
interruptConfigure.pressedEnable = 1;
136-
return writeSingleRegisterWithReadback(SFE_QWIIC_BUTTON_INTERRUPT_CONFIG, interruptConfigure.byteWrapped);
137-
}
138-
139-
uint8_t QwiicBuzzer::disablePressedInterrupt()
140-
{
141-
interruptConfigBitField interruptConfigure;
142-
interruptConfigure.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_INTERRUPT_CONFIG);
143-
interruptConfigure.pressedEnable = 0;
144-
return writeSingleRegisterWithReadback(SFE_QWIIC_BUTTON_INTERRUPT_CONFIG, interruptConfigure.byteWrapped);
145-
}
146-
147-
uint8_t QwiicBuzzer::enableClickedInterrupt()
148-
{
149-
interruptConfigBitField interruptConfigure;
150-
interruptConfigure.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_INTERRUPT_CONFIG);
151-
interruptConfigure.clickedEnable = 1;
152-
return writeSingleRegisterWithReadback(SFE_QWIIC_BUTTON_INTERRUPT_CONFIG, interruptConfigure.byteWrapped);
153-
}
154-
155-
uint8_t QwiicBuzzer::disableClickedInterrupt()
156-
{
157-
interruptConfigBitField interruptConfigure;
158-
interruptConfigure.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_INTERRUPT_CONFIG);
159-
interruptConfigure.clickedEnable = 0;
160-
return writeSingleRegisterWithReadback(SFE_QWIIC_BUTTON_INTERRUPT_CONFIG, interruptConfigure.byteWrapped);
161-
}
162-
163-
bool QwiicBuzzer::available()
164-
{
165-
statusRegisterBitField buttonStatus;
166-
buttonStatus.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_BUTTON_STATUS);
167-
return buttonStatus.eventAvailable;
168-
}
169-
170-
uint8_t QwiicBuzzer::clearEventBits()
171-
{
172-
statusRegisterBitField buttonStatus;
173-
buttonStatus.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_BUTTON_STATUS);
174-
buttonStatus.isPressed = 0;
175-
buttonStatus.hasBeenClicked = 0;
176-
buttonStatus.eventAvailable = 0;
177-
return writeSingleRegisterWithReadback(SFE_QWIIC_BUTTON_BUTTON_STATUS, buttonStatus.byteWrapped);
178-
}
179-
180-
uint8_t QwiicBuzzer::resetInterruptConfig()
181-
{
182-
interruptConfigBitField interruptConfigure;
183-
interruptConfigure.pressedEnable = 1;
184-
interruptConfigure.clickedEnable = 1;
185-
return writeSingleRegisterWithReadback(SFE_QWIIC_BUTTON_INTERRUPT_CONFIG, interruptConfigure.byteWrapped);
186-
statusRegisterBitField buttonStatus;
187-
buttonStatus.eventAvailable = 0;
188-
return writeSingleRegisterWithReadback(SFE_QWIIC_BUTTON_BUTTON_STATUS, buttonStatus.byteWrapped);
189-
}
190105

191-
/*------------------------- Queue Manipulation ---------------------- */
192-
//pressed queue manipulation
193-
bool QwiicBuzzer::isPressedQueueFull()
194-
{
195-
queueStatusBitField pressedQueueStatus;
196-
pressedQueueStatus.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_PRESSED_QUEUE_STATUS);
197-
return pressedQueueStatus.isFull;
198-
}
199-
200-
bool QwiicBuzzer::isPressedQueueEmpty()
201-
{
202-
queueStatusBitField pressedQueueStatus;
203-
pressedQueueStatus.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_PRESSED_QUEUE_STATUS);
204-
return pressedQueueStatus.isEmpty;
205-
}
206-
207-
unsigned long QwiicBuzzer::timeSinceLastPress()
208-
{
209-
return readQuadRegister(SFE_QWIIC_BUTTON_PRESSED_QUEUE_FRONT);
210-
}
211-
212-
unsigned long QwiicBuzzer::timeSinceFirstPress()
213-
{
214-
return readQuadRegister(SFE_QWIIC_BUTTON_PRESSED_QUEUE_BACK);
215-
}
216-
217-
unsigned long QwiicBuzzer::popPressedQueue()
218-
{
219-
unsigned long tempData = timeSinceFirstPress(); //grab the oldest value on the queue
220-
221-
queueStatusBitField pressedQueueStatus;
222-
pressedQueueStatus.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_PRESSED_QUEUE_STATUS);
223-
pressedQueueStatus.popRequest = 1;
224-
writeSingleRegister(SFE_QWIIC_BUTTON_PRESSED_QUEUE_STATUS, pressedQueueStatus.byteWrapped); //remove the oldest value from the queue
225-
226-
return tempData; //return the value we popped
227-
}
228-
229-
//clicked queue manipulation
230-
bool QwiicBuzzer::isClickedQueueFull()
231-
{
232-
queueStatusBitField clickedQueueStatus;
233-
clickedQueueStatus.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_CLICKED_QUEUE_STATUS);
234-
return clickedQueueStatus.isFull;
235-
}
236-
237-
bool QwiicBuzzer::isClickedQueueEmpty()
238-
{
239-
queueStatusBitField clickedQueueStatus;
240-
clickedQueueStatus.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_CLICKED_QUEUE_STATUS);
241-
return clickedQueueStatus.isEmpty;
242-
}
243-
244-
unsigned long QwiicBuzzer::timeSinceLastClick()
245-
{
246-
return readQuadRegister(SFE_QWIIC_BUTTON_CLICKED_QUEUE_FRONT);
247-
}
248-
249-
unsigned long QwiicBuzzer::timeSinceFirstClick()
250-
{
251-
return readQuadRegister(SFE_QWIIC_BUTTON_CLICKED_QUEUE_BACK);
252-
}
253-
254-
unsigned long QwiicBuzzer::popClickedQueue()
255-
{
256-
unsigned long tempData = timeSinceFirstClick();
257-
queueStatusBitField clickedQueueStatus;
258-
clickedQueueStatus.byteWrapped = readSingleRegister(SFE_QWIIC_BUTTON_CLICKED_QUEUE_STATUS);
259-
clickedQueueStatus.popRequest = 1;
260-
writeSingleRegister(SFE_QWIIC_BUTTON_CLICKED_QUEUE_STATUS, clickedQueueStatus.byteWrapped);
261-
return tempData;
262-
}
263106

264-
/*------------------------ LED Configuration ------------------------ */
107+
/*------------------------ BUZZER Configuration ------------------------ */
265108
bool QwiicBuzzer::BUZZERconfig(uint16_t toneFrequency, uint8_t volume, uint16_t offTime, uint8_t granularity)
266109
{
267110
bool success = writeSingleRegister(SFE_QWIIC_BUZZER_VOLUME, volume);
268-
success &= writeSingleRegister(SFE_QWIIC_BUTTON_LED_PULSE_GRANULARITY, granularity);
269111
success &= writeDoubleRegister(SFE_QWIIC_BUZZER_TONE_FREQUENCY, toneFrequency);
270-
success &= writeDoubleRegister(SFE_QWIIC_BUTTON_LED_PULSE_OFF_TIME, offTime);
271112
return success;
272113
}
273114

src/registers.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,7 @@ enum Qwiic_Button_Register : uint8_t
2828
SFE_QWIIC_BUTTON_FIRMWARE_MAJOR = 0x02,
2929
SFE_QWIIC_BUZZER_TONE_FREQUENCY = 0x03,
3030
SFE_QWIIC_BUZZER_VOLUME = 0x05,
31-
SFE_QWIIC_BUTTON_BUTTON_STATUS = 0x06,
32-
SFE_QWIIC_BUTTON_INTERRUPT_CONFIG = 0x07,
33-
SFE_QWIIC_BUTTON_BUTTON_DEBOUNCE_TIME = 0x08, //
34-
SFE_QWIIC_BUTTON_PRESSED_QUEUE_STATUS = 0x0A,
35-
SFE_QWIIC_BUTTON_PRESSED_QUEUE_FRONT = 0x0B, //
36-
SFE_QWIIC_BUTTON_PRESSED_QUEUE_BACK = 0x0F,
37-
SFE_QWIIC_BUTTON_CLICKED_QUEUE_STATUS = 0x13,
38-
SFE_QWIIC_BUTTON_CLICKED_QUEUE_FRONT = 0x14,
39-
SFE_QWIIC_BUTTON_CLICKED_QUEUE_BACK = 0x18,
40-
41-
SFE_QWIIC_BUTTON_LED_PULSE_GRANULARITY = 0x1C,
42-
SFE_QWIIC_BUTTON_LED_PULSE_OFF_TIME = 0x1D,
43-
SFE_QWIIC_BUTTON_I2C_ADDRESS = 0x1F,
31+
SFE_QWIIC_BUTTON_I2C_ADDRESS = 0x06,
4432
};
4533

4634
typedef union {

0 commit comments

Comments
 (0)