Skip to content

Commit

Permalink
Various fixes and shut off leds
Browse files Browse the repository at this point in the history
Fixes Tray icon "Quit Application" crashing
Fixes auto-start with windows wrongly guessing when it really was an
auto start
Added a shut down LEDs mode
Changed behavior of the firmware so that when it loses connection with
the app it returns to rainbow mode by default.
  • Loading branch information
BrianLima committed Aug 11, 2017
1 parent a5955af commit d616562
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 27 deletions.
10 changes: 10 additions & 0 deletions HueHue/Helpers/Effects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,15 @@ public static void ColorCycle()

FixedColor(); //Fill the strip with the color
}

public static void Black()
{
foreach (LEDBulb LED in LEDs)
{
LED.R =0;
LED.B = 0;
LED.G = 0;
}
}
}
}
1 change: 0 additions & 1 deletion HueHue/Helpers/SerialStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public SerialStream()
{
}

// public List<LEDBulb> LEDS = new List<LEDBulb>();
private ILogger _log = LogManager.GetCurrentClassLogger();

private readonly byte[] _messagePreamble = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };
Expand Down
1 change: 1 addition & 0 deletions HueHue/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<Label Content="Color Cycling"/>
<Label Content="Snake Color"/>
<Label Content="Breathing"/>
<Label Content="Shut Off"/>
</ComboBox>
<TextBlock HorizontalAlignment="Left" Margin="32,79,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="18" Width="34" Text="Effect:" Grid.Row="1"/>
<TextBox x:Name="textBox" Text="{Binding TotalLeds}" Height="27" TextWrapping="Wrap" VerticalAlignment="Top" Margin="71,35,10.4,0" TextAlignment="Right" Grid.Row="1"/>
Expand Down
5 changes: 4 additions & 1 deletion HueHue/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public MainWindow()
icon = new TrayIcon();

//The app was auto started by windows from the user's startup folder
if (settings.AutoStart && Environment.GetCommandLineArgs() != null)
if (settings.AutoStart && Environment.GetCommandLineArgs().Length > 1)
{
this.Minimize();
StartStop();
Expand Down Expand Up @@ -92,6 +92,9 @@ private void comboBox_SelectionChanged(object sender, System.Windows.Controls.Se
case 4:
frame.Navigate(new SnakeMode(settings));
break;
case 5:
Effects.Black();
break;

default:
break;
Expand Down
2 changes: 1 addition & 1 deletion HueHue/Views/TrayIcon.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<tb:TaskbarIcon ToolTipText="HueHue LED Controler" x:Name="icon" TrayMouseDoubleClick="icon_TrayMouseDoubleClick">
<tb:TaskbarIcon.ContextMenu>
<ContextMenu >
<MenuItem Header="Shut off LEDs" FontFamily="Segoe UI Light" FontSize="14" />
<MenuItem Header="Shut off LEDs" FontFamily="Segoe UI Light" FontSize="14" Click="MenuItem_ShutOff_Click" />
<MenuItem Header="Quit" FontFamily="Segoe UI Light" FontSize="14" Click="MenuItem_Quit_Click" x:Name="menuItem_Quit"/>
</ContextMenu>
</tb:TaskbarIcon.ContextMenu>
Expand Down
21 changes: 8 additions & 13 deletions HueHue/Views/TrayIcon.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
using Hardcodet.Wpf.TaskbarNotification;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HueHue.Helpers;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace HueHue.Views
{
Expand All @@ -38,7 +28,12 @@ private void icon_TrayMouseDoubleClick(object sender, RoutedEventArgs e)

private void MenuItem_Quit_Click(object sender, RoutedEventArgs e)
{
App.Current.MainWindow.Close();
Process.GetCurrentProcess().Kill();
}

private void MenuItem_ShutOff_Click(object sender, RoutedEventArgs e)
{
Effects.FixedColor();
}
}
}
3 changes: 2 additions & 1 deletion HueHueClient/HueHueClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ void processIncomingData()
{
//if we get here, there must have been data before(so the user already knows, it works!)
//simply go to black!
mode = MODE_BLACK;
//mode = MODE_BLACK; //If the arduino stops receiving commands, shut down the LEDs
mode = MODE_ANIMATION; //If the Arduino stops receiving commands, start the rainbow effect
}
}

Expand Down
4 changes: 2 additions & 2 deletions HueHueClient/HueHueClient.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\Arduino\libraries\FastLED;$(ProjectDir)..\..\..\..\..\..\Program Files (x86)\Arduino\libraries;$(ProjectDir)..\..\..\..\AppData\Local\arduino15\packages\arduino\hardware\avr\1.6.17\libraries;$(ProjectDir)..\..\..\Arduino\libraries;$(ProjectDir)..\..\..\..\AppData\Local\arduino15\packages\arduino\hardware\avr\1.6.17\cores\arduino;$(ProjectDir)..\..\..\..\AppData\Local\arduino15\packages\arduino\hardware\avr\1.6.17\variants\eightanaloginputs;$(ProjectDir)..\HueHueClient;$(ProjectDir)..\..\..\..\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2\avr\include\;$(ProjectDir)..\..\..\..\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2\avr\include\avr\;$(ProjectDir)..\..\..\..\AppData\Local\arduino15\packages\arduino\tools\avr-gcc\4.9.2-atmel3.5.3-arduino2\lib\gcc\avr\4.8.1\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\Arduino\libraries\FastLED-3.1.3;C:\Program Files (x86)\Arduino\libraries;C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries;$(ProjectDir)..\..\..\Arduino\libraries;C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino;C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs;$(ProjectDir)..\HueHueClient;C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include\;C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include\avr\;C:\Program Files (x86)\Arduino\hardware\tools\avr\lib\gcc\avr\4.8.1\include;C:\Program Files (x86)\Arduino\hardware\tools\avr\lib\gcc\avr\4.9.2\include;C:\Program Files (x86)\Arduino\hardware\tools\avr\lib\gcc\avr\4.9.3\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>$(ProjectDir)__vm\.HueHueClient.vsarduino.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
<PreprocessorDefinitions>__AVR_ATmega328p__;__AVR_ATmega328P__;_VMDEBUG=1;F_CPU=16000000L;ARDUINO=10802;ARDUINO_AVR_NANO;ARDUINO_ARCH_AVR;__cplusplus=201103L;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>__AVR_ATmega328p__;__AVR_ATmega328P__;_VMDEBUG=1;F_CPU=16000000L;ARDUINO=10803;ARDUINO_AVR_NANO;ARDUINO_ARCH_AVR;__cplusplus=201103L;_VMICRO_INTELLISENSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand Down
28 changes: 20 additions & 8 deletions HueHueClient/__vm/.HueHueClient.vsarduino.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
/*
Editor: http://www.visualmicro.com
visual micro and the arduino ide ignore this code during compilation. this code is automatically maintained by visualmicro, manual changes to this file will be overwritten
the contents of the Visual Micro sketch sub folder can be deleted prior to publishing a project
all non-arduino files created by visual micro and all visual studio project or solution files can be freely deleted and are not required to compile a sketch (do not delete your own code!).
note: debugger breakpoints are stored in '.sln' or '.asln' files, knowledge of last uploaded breakpoints is stored in the upload.vmps.xml file. Both files are required to continue a previous debug session without needing to compile and upload again
visual micro and the arduino ide ignore this code during compilation. this code is automatically maintained by visualmicro, manual changes to this file will be overwritten
the contents of the Visual Micro sketch sub folder can be deleted prior to publishing a project
all non-arduino files created by visual micro and all visual studio project or solution files can be freely deleted and are not required to compile a sketch (do not delete your own code!).
note: debugger breakpoints are stored in '.sln' or '.asln' files, knowledge of last uploaded breakpoints is stored in the upload.vmps.xml file. Both files are required to continue a previous debug session without needing to compile and upload again
Hardware: Arduino Nano w/ ATmega328, Platform=avr, Package=arduino
*/

#if defined(_VMICRO_INTELLISENSE)

#ifndef _VSARDUINO_H_
#define _VSARDUINO_H_
#define __AVR_ATmega328p__
#define __AVR_ATmega328P__
#define _VMDEBUG 1
#define F_CPU 16000000L
#define ARDUINO 10802
#define ARDUINO 10803
#define ARDUINO_AVR_NANO
#define ARDUINO_ARCH_AVR
#define __cplusplus 201103L
#define __AVR__
#define __inline__
#define __asm__(x)
#define __asm__(...)
#define __extension__
#define __inline__
#define __volatile__
Expand All @@ -34,7 +36,7 @@
#define _CONST
#define __builtin_va_start
#define __builtin_va_end
#define __attribute__(x)
#define __attribute__(...)
#define NOINLINE __attribute__((noinline))
#define prog_void
#define PGM_VOID_P int
Expand All @@ -47,6 +49,7 @@
#define __builtin_strlen __attribute__((__const__))
#endif


#define NEW_H
typedef void *__builtin_va_list;
//extern "C" void __cxa_pure_virtual() {;}
Expand All @@ -60,11 +63,20 @@ typedef void *__builtin_va_list;



#include <arduino.h>
#include <Arduino.h>
#include <pins_arduino.h>
#undef F
#define F(string_literal) ((const PROGMEM char *)(string_literal))
#undef PSTR
#define PSTR(string_literal) ((const PROGMEM char *)(string_literal))


#define pgm_read_byte(address_short) uint8_t()
#define pgm_read_word(address_short) uint16_t()
#define pgm_read_dword(address_short) uint32_t()
#define pgm_read_float(address_short) float()
#define pgm_read_ptr(address_short) short()

#include "HueHueClient.ino"
#endif
#endif

0 comments on commit d616562

Please sign in to comment.