projects
/
pub
/
lufa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Enhance the HotmailNotifier project so that the LEDs' individual brightness can be...
[pub/lufa.git]
/
Projects
/
HotmailNotifier
/
WindowsApp
/
MailNotifier.cs
diff --git
a/Projects/HotmailNotifier/WindowsApp/MailNotifier.cs
b/Projects/HotmailNotifier/WindowsApp/MailNotifier.cs
index
d7f0516
..
742948f
100644
(file)
--- a/
Projects/HotmailNotifier/WindowsApp/MailNotifier.cs
+++ b/
Projects/HotmailNotifier/WindowsApp/MailNotifier.cs
@@
-12,18
+12,20
@@
namespace TestWinForms
public partial class MailNotifier : Form
\r
{
\r
private MessengerAPI.Messenger Messenger;
\r
public partial class MailNotifier : Form
\r
{
\r
private MessengerAPI.Messenger Messenger;
\r
- private RegistryKey AppRegKey;
\r
+ private RegistryKey AppRegKey;
\r
+
\r
+ private const int LIGHT_MAX = 0x1F;
\r
\r
public MailNotifier()
\r
{
\r
InitializeComponent();
\r
\r
Messenger = new MessengerAPI.Messenger();
\r
\r
public MailNotifier()
\r
{
\r
InitializeComponent();
\r
\r
Messenger = new MessengerAPI.Messenger();
\r
-
AppRegKey = Registry.CurrentUser.CreateSubKey("Software\\MailNotifier");
\r
+ AppRegKey = Registry.CurrentUser.CreateSubKey("Software\\MailNotifier");
\r
\r
for (int i = 1; i < 99; i++)
\r
cmbComPort.Items.Add("COM" + i.ToString());
\r
\r
for (int i = 1; i < 99; i++)
\r
cmbComPort.Items.Add("COM" + i.ToString());
\r
-
\r
+
\r
cmbComPort.SelectedIndex = System.Convert.ToInt32(AppRegKey.GetValue("Port", "1")) - 1;
\r
serSerialPort.PortName = cmbComPort.Text;
\r
\r
cmbComPort.SelectedIndex = System.Convert.ToInt32(AppRegKey.GetValue("Port", "1")) - 1;
\r
serSerialPort.PortName = cmbComPort.Text;
\r
\r
@@
-34,7
+36,9
@@
namespace TestWinForms
private void MailNotifier_Load(object sender, EventArgs e)
\r
{
\r
Messenger.OnUnreadEmailChange += new MessengerAPI.DMessengerEvents_OnUnreadEmailChangeEventHandler(NewEmail);
\r
private void MailNotifier_Load(object sender, EventArgs e)
\r
{
\r
Messenger.OnUnreadEmailChange += new MessengerAPI.DMessengerEvents_OnUnreadEmailChangeEventHandler(NewEmail);
\r
- NotifyLight(Messenger.get_UnreadEmailCount(MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX) > 0);
\r
+
\r
+ bool UnreadMail = (Messenger.get_UnreadEmailCount(MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX) > 0);
\r
+ NotifyLight((!UnreadMail ? LIGHT_MAX : 0), (UnreadMail ? LIGHT_MAX : 0), 0);
\r
\r
Hide();
\r
}
\r
\r
Hide();
\r
}
\r
@@
-48,18
+52,23
@@
namespace TestWinForms
private void NewEmail(MessengerAPI.MUAFOLDER folder, int amount, ref bool enableDefault)
\r
{
\r
if (folder == MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX)
\r
private void NewEmail(MessengerAPI.MUAFOLDER folder, int amount, ref bool enableDefault)
\r
{
\r
if (folder == MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX)
\r
- NotifyLight(amount > 0);
\r
+ {
\r
+ bool UnreadMail = (Messenger.get_UnreadEmailCount(MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX) > 0);
\r
+ NotifyLight((!UnreadMail ? LIGHT_MAX : 0), (UnreadMail ? LIGHT_MAX : 0), 0);
\r
+ }
\r
}
\r
\r
}
\r
\r
- private void NotifyLight(
bool ShowGreen
)
\r
+ private void NotifyLight(
int Red, int Green, int Blue
)
\r
{
\r
{
\r
- char[] buffer = new char[1];
\r
- buffer[0] = ShowGreen ? '0' : '1';
\r
+ byte[] buffer = new byte[3];
\r
+ buffer[0] = (byte)(0x80 | (Red & LIGHT_MAX));
\r
+ buffer[1] = (byte)(0x40 | (Green & LIGHT_MAX));
\r
+ buffer[2] = (byte)(0x20 | (Blue & LIGHT_MAX));
\r
\r
try
\r
{
\r
serSerialPort.Open();
\r
\r
try
\r
{
\r
serSerialPort.Open();
\r
- serSerialPort.Write(buffer, 0,
1
);
\r
+ serSerialPort.Write(buffer, 0,
buffer.Length
);
\r
serSerialPort.Close();
\r
}
\r
catch (Exception e)
\r
serSerialPort.Close();
\r
}
\r
catch (Exception e)
\r
@@
-78,15
+87,20
@@
namespace TestWinForms
AppRegKey.SetValue("Port", cmbComPort.SelectedIndex + 1);
\r
serSerialPort.PortName = cmbComPort.Text;
\r
\r
AppRegKey.SetValue("Port", cmbComPort.SelectedIndex + 1);
\r
serSerialPort.PortName = cmbComPort.Text;
\r
\r
- for (int i = 0; i < 5; i++)
\r
+ for (int i = 1; i < 10; i++)
\r
+ {
\r
+ NotifyLight((LIGHT_MAX / i), (LIGHT_MAX / (i * 10)), 0);
\r
+ System.Threading.Thread.Sleep(10);
\r
+ }
\r
+
\r
+ for (int i = 10; i > 0; i--)
\r
{
\r
{
\r
- NotifyLight(true);
\r
- System.Threading.Thread.Sleep(20);
\r
- NotifyLight(false);
\r
- System.Threading.Thread.Sleep(20);
\r
+ NotifyLight((LIGHT_MAX / i), (LIGHT_MAX / (i * 10)), 0);
\r
+ System.Threading.Thread.Sleep(10);
\r
}
\r
\r
}
\r
\r
- NotifyLight(Messenger.get_UnreadEmailCount(MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX) > 0);
\r
+ bool UnreadMail = (Messenger.get_UnreadEmailCount(MessengerAPI.MUAFOLDER.MUAFOLDER_INBOX) > 0);
\r
+ NotifyLight((!UnreadMail ? LIGHT_MAX : 0), (UnreadMail ? LIGHT_MAX : 0), 0);
\r
}
\r
\r
private void btnMinimize_Click(object sender, EventArgs e)
\r
}
\r
\r
private void btnMinimize_Click(object sender, EventArgs e)
\r