diff --git a/LUFA.pnproj b/LUFA.pnproj index 35d05174fd..9ffcdb9c7f 100644 --- a/LUFA.pnproj +++ b/LUFA.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/LUFA/ManPages/AlternativeStacks.txt b/LUFA/ManPages/AlternativeStacks.txt new file mode 100644 index 0000000000..ed640f4ab7 --- /dev/null +++ b/LUFA/ManPages/AlternativeStacks.txt @@ -0,0 +1,37 @@ +/** \file + * + * This file contains special DoxyGen information for the generation of the main page and other special + * documentation pages. It is not a project source file. + */ + +/** + * \page Page_AlternativeStacks Alternative USB AVR Stacks + * + * LUFA is not the only stack available for the USB AVRs, although it is perhaps the best (\see Page_WhyUseLUFA). + * In the interests of completeness and user choice, other known USB AVR stacks are listed here. + * + * - Atmel USB AVR Stack (Atmel Inc.) \n + * Cost: Free \n + * License: Atmel Limited License (see Atmel download for details) \n + * Website: http://atmel.com/dyn/products/app_notes.asp?family_id=607#USB \n + * Description: This is the official Atmel USB AVR stack, for their 8-bit USB AVR lineup. Each series of + * USB AVR is seperated into a seperate download stack, which is both AVR-GCC and IAR compatible. + * + * - Dr. Stefan Salewski's AT90USB1287 Stack (Dr. Stefan Salewski) \n + * Cost: Free \n + * License: GPL \n + * Website: http://www.ssalewski.de/AT90USB_firmware.html.en \n + * Description: This is a GPL'd library specifically designed for the AT90USB1287, by Dr. Stefan Salewski, a + * German Physicist. It compiles for AVR-GCC and can potentially be modified to work on other USB + * AVR models. + * + * - PJRC Teensy Stack (Paul Stoffregen) \n + * Cost: Free \n + * License: BSD \n + * Website: http://www.pjrc.com/teensy/usb_debug_only.html \n + * Description: Not so much a complete stack as a collection of USB enabled demos, this library is specifically + * designed for the PJRC Teensy line of USB AVRs, and thus may need to be modified for other USB AVR + * chips. These code samples shows the inner workings of the USB controller, without all the abstraction + * present in most other USB AVR stacks. + */ + \ No newline at end of file diff --git a/LUFA/ManPages/FutureChanges.txt b/LUFA/ManPages/FutureChanges.txt index 3267afc73d..07b2f83949 100644 --- a/LUFA/ManPages/FutureChanges.txt +++ b/LUFA/ManPages/FutureChanges.txt @@ -17,6 +17,7 @@ * -# Add ability to get number of bytes not written with pipe/endpoint write routines after an error * -# Add standardized descriptor names to class driver structures * -# Correct mishandling of error cases in Mass Storage demos + * -# Add TPI programming support to the AVRISP project * - Documentation/Support * -# Remake AVRStudio project files * -# Add detailed overviews of how each demo works diff --git a/LUFA/ManPages/MainPage.txt b/LUFA/ManPages/MainPage.txt index 0626cdb610..8fe197f16a 100644 --- a/LUFA/ManPages/MainPage.txt +++ b/LUFA/ManPages/MainPage.txt @@ -33,8 +33,9 @@ * Subsections: * - \subpage Page_WhyUseLUFA Why Use LUFA? * - \subpage Page_LUFAvsAtmelStack How does LUFA compare to the Atmel USB AVR stack? + * - \subpage Page_AlternativeStacks Alternative USB AVR Stacks * - \subpage Page_Licence Project licence - * - \subpage Page_Donating Donating to Support this Project + * - \subpage Page_Donating Donating to support this project * - \subpage Page_LibraryApps Overview of included Demos, Bootloaders and Projects * * Logo design by EDIGMA.COM diff --git a/Projects/HotmailNotifier/HotmailNotifier.c b/Projects/HotmailNotifier/HotmailNotifier.c index 3d467e54ad..5a7ebd563f 100644 --- a/Projects/HotmailNotifier/HotmailNotifier.c +++ b/Projects/HotmailNotifier/HotmailNotifier.c @@ -60,6 +60,39 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = }, }; +/** Counter for the software PWM */ +static volatile uint8_t SoftPWM_Count; + +/** Duty cycle for the first software PWM channel */ +static volatile uint8_t SoftPWM_Channel1_Duty; + +/** Duty cycle for the second software PWM channel */ +static volatile uint8_t SoftPWM_Channel2_Duty; + +/** Duty cycle for the third software PWM channel */ +static volatile uint8_t SoftPWM_Channel3_Duty; + + +/** Interrupt handler for managing the software PWM channels for the LEDs */ +ISR(TIMER0_COMPA_vect, ISR_BLOCK) +{ + uint8_t LEDMask = LEDS_ALL_LEDS; + + if (++SoftPWM_Count == 0x1F) + SoftPWM_Count = 0; + + if (SoftPWM_Count >= SoftPWM_Channel1_Duty) + LEDMask &= ~LEDS_LED1; + + if (SoftPWM_Count >= SoftPWM_Channel2_Duty) + LEDMask &= ~LEDS_LED2; + + if (SoftPWM_Count >= SoftPWM_Channel3_Duty) + LEDMask &= ~LEDS_LED3; + + LEDs_SetAllLEDs(LEDMask); +} + /** Standard file stream for the CDC interface when set up, so that the virtual CDC COM port can be * used like any regular character stream in the C APIs */ @@ -77,11 +110,21 @@ int main(void) for (;;) { - /* Read next character - if a '1' turn on red led, if a '0' turn on green LED */ - if (fgetc(&USBSerialStream) == '1') - LEDs_SetAllLEDs(LEDS_LED3); - else - LEDs_SetAllLEDs(LEDS_LED2); + /* Read in next LED colour command from the host */ + uint8_t ColorUpdate = fgetc(&USBSerialStream); + + /* Top 3 bits select the LED, bottom three control the brightness */ + uint8_t Channel = (ColorUpdate & 0b11100000); + uint8_t Duty = (ColorUpdate & 0b00011111); + + if (Channel & (1 << 5)) + SoftPWM_Channel1_Duty = Duty; + + if (Channel & (1 << 6)) + SoftPWM_Channel2_Duty = Duty; + + if (Channel & (1 << 7)) + SoftPWM_Channel3_Duty = Duty; CDC_Device_USBTask(&VirtualSerial_CDC_Interface); USB_USBTask(); @@ -101,15 +144,18 @@ void SetupHardware(void) /* Hardware Initialization */ LEDs_Init(); USB_Init(); + + /* Timer Initialization */ + OCR0A = 100; + TCCR0A = (1 << WGM01); + TCCR0B = (1 << CS00); + TIMSK0 = (1 << OCIE0A); } /** Event handler for the library USB Configuration Changed event. */ void EVENT_USB_Device_ConfigurationChanged(void) { - LEDs_SetAllLEDs(LEDS_ALL_LEDS); - - if (!(CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface))) - LEDs_SetAllLEDs(LEDS_LED1 | LEDS_LED3); + CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface); } /** Event handler for the library USB Unhandled Control Request event. */ diff --git a/Projects/HotmailNotifier/WindowsApp/MailNotifier.cs b/Projects/HotmailNotifier/WindowsApp/MailNotifier.cs index d7f0516874..742948fcab 100644 --- a/Projects/HotmailNotifier/WindowsApp/MailNotifier.cs +++ b/Projects/HotmailNotifier/WindowsApp/MailNotifier.cs @@ -12,18 +12,20 @@ namespace TestWinForms public partial class MailNotifier : Form { private MessengerAPI.Messenger Messenger; - private RegistryKey AppRegKey; + private RegistryKey AppRegKey; + + private const int LIGHT_MAX = 0x1F; public MailNotifier() { InitializeComponent(); Messenger = new MessengerAPI.Messenger(); - AppRegKey = Registry.CurrentUser.CreateSubKey("Software\\MailNotifier"); + AppRegKey = Registry.CurrentUser.CreateSubKey("Software\\MailNotifier"); for (int i = 1; i < 99; i++) cmbComPort.Items.Add("COM" + i.ToString()); - + cmbComPort.SelectedIndex = System.Convert.ToInt32(AppRegKey.GetValue("Port", "1")) - 1; serSerialPort.PortName = cmbComPort.Text; @@ -34,7 +36,9 @@ namespace TestWinForms private void MailNotifier_Load(object sender, EventArgs e) { Messenger.OnUnreadEmailChange += new MessengerAPI.DMessengerEvents_OnUnreadEmailChangeEventHandler(NewEmail); - NotifyLight(Messenger.get_UnreadEmailCount(MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX) > 0); + + bool UnreadMail = (Messenger.get_UnreadEmailCount(MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX) > 0); + NotifyLight((!UnreadMail ? LIGHT_MAX : 0), (UnreadMail ? LIGHT_MAX : 0), 0); Hide(); } @@ -48,18 +52,23 @@ namespace TestWinForms private void NewEmail(MessengerAPI.MUAFOLDER folder, int amount, ref bool enableDefault) { if (folder == MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX) - NotifyLight(amount > 0); + { + bool UnreadMail = (Messenger.get_UnreadEmailCount(MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX) > 0); + NotifyLight((!UnreadMail ? LIGHT_MAX : 0), (UnreadMail ? LIGHT_MAX : 0), 0); + } } - private void NotifyLight(bool ShowGreen) + private void NotifyLight(int Red, int Green, int Blue) { - char[] buffer = new char[1]; - buffer[0] = ShowGreen ? '0' : '1'; + byte[] buffer = new byte[3]; + buffer[0] = (byte)(0x80 | (Red & LIGHT_MAX)); + buffer[1] = (byte)(0x40 | (Green & LIGHT_MAX)); + buffer[2] = (byte)(0x20 | (Blue & LIGHT_MAX)); try { serSerialPort.Open(); - serSerialPort.Write(buffer, 0, 1); + serSerialPort.Write(buffer, 0, buffer.Length); serSerialPort.Close(); } catch (Exception e) @@ -78,15 +87,20 @@ namespace TestWinForms AppRegKey.SetValue("Port", cmbComPort.SelectedIndex + 1); serSerialPort.PortName = cmbComPort.Text; - for (int i = 0; i < 5; i++) + for (int i = 1; i < 10; i++) { - NotifyLight(true); - System.Threading.Thread.Sleep(20); - NotifyLight(false); - System.Threading.Thread.Sleep(20); + NotifyLight((LIGHT_MAX / i), (LIGHT_MAX / (i * 10)), 0); + System.Threading.Thread.Sleep(10); } - NotifyLight(Messenger.get_UnreadEmailCount(MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX) > 0); + for (int i = 10; i > 0; i--) + { + NotifyLight((LIGHT_MAX / i), (LIGHT_MAX / (i * 10)), 0); + System.Threading.Thread.Sleep(10); + } + + bool UnreadMail = (Messenger.get_UnreadEmailCount(MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX) > 0); + NotifyLight((!UnreadMail ? LIGHT_MAX : 0), (UnreadMail ? LIGHT_MAX : 0), 0); } private void btnMinimize_Click(object sender, EventArgs e)