Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Firmware/.dep/
Firmware/.settings
Firmware/.project
Firmware/.cproject
Software/[^.]*Makefile
Software/**/Makefile*
Software/res/qrc_[^.]+.cpp
Software/res/translations/*.qm
Software/[^.]+.pro.user
Expand Down Expand Up @@ -53,7 +53,6 @@ stuff/
*.sym
Software/dmg/contents
build-vars.prf
Makefile*
debug/
release/
Software/dist_windows/content
Expand Down
8 changes: 6 additions & 2 deletions CommonHeaders/COMMANDS.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/


#ifndef COMMANDS_H_INCLUDED
#define COMMANDS_H_INCLUDED
Expand All @@ -37,7 +37,10 @@ enum COMMANDS{
CMD_SET_SMOOTH_SLOWDOWN,
CMD_SET_BRIGHTNESS,

CMD_NOP = 0x0F
CMD_NOP = 0x0F,

// Unofficial commands
CMD_UNOFFICIAL_SET_USBLED = 0x81,
};

enum PRESCALLERS{
Expand All @@ -52,6 +55,7 @@ enum PRESCALLERS{
enum DATA_VERSION_INDEXES{
INDEX_FW_VER_MAJOR = 1,
INDEX_FW_VER_MINOR,
INDEX_FW_VER_UNOFFICIAL = 5 // Use index 5 just in case the official firmware gets updated to use index 3 and 4 (0.0.0.0 version format)
};

#endif /* COMMANDS_H_INCLUDED */
8 changes: 6 additions & 2 deletions CommonHeaders/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/


#ifndef COMMANDS_H_INCLUDED
#define COMMANDS_H_INCLUDED
Expand All @@ -37,7 +37,10 @@ enum COMMANDS{
CMD_SET_SMOOTH_SLOWDOWN,
CMD_SET_BRIGHTNESS,

CMD_NOP = 0x0F
CMD_NOP = 0x0F,

// Unofficial commands
CMD_UNOFFICIAL_SET_USBLED = 0x81,
};

enum PRESCALLERS{
Expand All @@ -52,6 +55,7 @@ enum PRESCALLERS{
enum DATA_VERSION_INDEXES{
INDEX_FW_VER_MAJOR = 1,
INDEX_FW_VER_MINOR,
INDEX_FW_VER_UNOFFICIAL = 5 // Use index 5 just in case the official firmware gets updated to use index 3 and 4 (0.0.0.0 version format)
};

#endif /* COMMANDS_H_INCLUDED */
3 changes: 3 additions & 0 deletions Firmware/Lightpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Settings_t g_Settings =

// Timer OCR value
.timerOutputCompareRegValue = 100,

// The enabled state of the blue USB LED on the back of the device
.isUsbLedEnabled = true,
};

/*
Expand Down
16 changes: 15 additions & 1 deletion Firmware/LightpackUSB.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
// Firmware version
ReportData_u8[INDEX_FW_VER_MAJOR] = VERSION_OF_FIRMWARE_MAJOR;
ReportData_u8[INDEX_FW_VER_MINOR] = VERSION_OF_FIRMWARE_MINOR;
ReportData_u8[INDEX_FW_VER_UNOFFICIAL] = VERSION_OF_FIRMWARE_UNOFFICIAL;
return true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't test this - all bytes in ReportData_u8 are zero unless set here?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, before this function is called the whole array is set to zero.
Also, the array is 64 bytes long, so there can't be a buffer overrun.

}

Expand All @@ -115,7 +116,7 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
const void* ReportData,
const uint16_t ReportSize)
{

uint8_t *ReportData_u8 = (uint8_t *)ReportData;

uint8_t cmd = ReportData_u8[0]; //[0]; // command from enum COMMANDS{ ... };
Expand Down Expand Up @@ -211,6 +212,19 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
case CMD_NOP:
break;


// Unofficial commands
case CMD_UNOFFICIAL_SET_USBLED:

g_Settings.isUsbLedEnabled = ReportData_u8[1];
if (g_Settings.isUsbLedEnabled) {
SET(USBLED);
} else {
CLR(USBLED);
}

break;

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have never looked into the firmware build. Are the settings persisted across device reboots?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, they are not persistent.
That may not really be a problem, because whenever Prismatik is started it writes all settings to the device.
When the device is disconnected Prismatik will also write the settings when the device is reconnected again.

}
}

Expand Down
Loading