Sfoglia il codice sorgente

Volume characters

# Conflicts:
#	main.c

Inverted volume
jancoow 9 anni fa
parent
commit
0a231a0e75
7 ha cambiato i file con 93 aggiunte e 30 eliminazioni
  1. 15 0
      display.c
  2. 2 2
      display.h
  3. 16 1
      displayHandler.c
  4. 1 0
      displayHandler.h
  5. 18 18
      keyboard.c
  6. 2 2
      keyboard.h
  7. 39 7
      main.c

+ 15 - 0
display.c

@@ -278,6 +278,21 @@ void LcdArrayLineTwo(char *data, int size){
 	}
 }
 
+void setXCursorPos(int leftRight,int count)
+{
+    int i;
+    for ( i = 0; i <count ; ++i)
+    {
+        switch(leftRight)
+        {
+            case 0: LcdWriteByte(1,0x18);		// shift rechts
+                break;
+            case 1: LcdWriteByte(1,0x1c);		// shift links
+                break;
+        }
+    }
+}
+
 /* ---------- end of module ------------------------------------------------ */
 	
 /*@}*/

+ 2 - 2
display.h

@@ -57,9 +57,9 @@ extern void LcdLowLevelInit(void);
 extern void ClearLcd(void);
 extern void LcdArrayLineOne(char*, int);
 extern void LcdArrayLineTwo(char*, int);
-
+extern void setXCursorPos(int,int);
 #endif /* _Display_H */
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*  ����  End Of File  �������� �������������������������������������������� */
 
 
 

+ 16 - 1
displayHandler.c

@@ -78,7 +78,7 @@ void displayAlarm(int line_number, int line_numberTwo)
 		str2[i] = data[i];
 	}
 	//LogMsg_P(LOG_INFO, PSTR("%d"), str2);
-    //sprintf(str2,"     Wekker     ");
+    sprintf(str2,"     Wekker     ");
 	//LogMsg_P(LOG_INFO, PSTR("%d"), str2);
     if (line_numberTwo > -1 && line_numberTwo < 2){
         (*write_display_ptr[line_numberTwo])(str2, 16);
@@ -86,5 +86,20 @@ void displayAlarm(int line_number, int line_numberTwo)
     }
 }
 
+void displayVolume(int pos)
+{
+    ClearLcd();
+    int i;
+    LcdArrayLineOne("     Volume     ", 16);
+
+    char characters[17];
+
+    for(i = 0; i < 17; i++)
+    {
+        characters[i] = 0xFF;
+    }
+        LcdArrayLineTwo(characters,pos);
+}
+
 
 

+ 1 - 0
displayHandler.h

@@ -8,4 +8,5 @@
 void displayTime(int);
 void displayDate(int);
 void displayAlarm(int line_number, int line_numberTwo);
+void displayVolume(int pos);
 #endif //MUTLI_OS_BUILD_DISPLAYHANDLER_H

+ 18 - 18
keyboard.c

@@ -75,7 +75,7 @@ static u_char KbRemapKey(u_short LongKey);
 
 
 
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 /*!
  * \brief Clear the eventbuffer of this module
  *
@@ -83,7 +83,7 @@ static u_char KbRemapKey(u_short LongKey);
  *
  * \param *pEvent pointer to the event queue
  */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 static void KbClearEvent(HANDLE *pEvent)
 {
     NutEnterCritical();
@@ -93,7 +93,7 @@ static void KbClearEvent(HANDLE *pEvent)
     NutExitCritical();
 }
 
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 /*!
  * \brief Low-level keyboard scan
  *
@@ -102,8 +102,8 @@ static void KbClearEvent(HANDLE *pEvent)
  *
  * After each keyboard-scan, check for a valid MMCard
  */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
-int KbScan()
+/* ����������������������������������������������������������������������� */
+void KbScan()
 {
     u_char KeyNibble0, KeyNibble1, KeyNibble2, KeyNibble3;
 
@@ -156,17 +156,17 @@ int KbScan()
     KeyFound |= (KeyNibble1 & 0x00F0);          // b7..b4 in 'KeyNibble1' to b7...b4  in 'KeyFound' -- do nothing
     KeyFound |= ((KeyNibble2<<4) & 0x0F00);     // b7..b4 in 'KeyNibble2' to b11..b8  in 'KeyFound' << shift 4 left
     KeyFound |= ((KeyNibble3<<8) & 0xF000);     // b7..b4 in 'KeyNibble3' to b15..b12 in 'KeyFound' << shift 8 left
-	return KeyFound;
+    KbInjectKey(KbRemapKey(KeyFound));
 #endif  // USE_JTAG
 
 }
 
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 /*!
  * \brief Remap the 16-bit value for the active key to an 8-bit value
  *
  */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 static u_char KbRemapKey(u_short LongKey)
 {
     switch (LongKey)
@@ -192,25 +192,25 @@ static u_char KbRemapKey(u_short LongKey)
     }
 }
 
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 /*!
  * \brief Return the repeating property for this key
  *
  * \return 'TRUE' in case the key was repeating, 'FALSE' if not
  *
  */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 static u_char KbKeyIsRepeating(u_short Key)
 {
     return(KeyRepeatArray[KbRemapKey(Key)]==KEY_REPEAT);
 }
 
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 /*!
  * \brief set the property of this key to repeating or not-repeating
  *
  */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 void KbSetKeyRepeating(u_char Key, u_char Property)
 {
     // check arguments
@@ -220,7 +220,7 @@ void KbSetKeyRepeating(u_char Key, u_char Property)
     }
 }
 
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 /*!
  * \brief Wait until an event was pushed on the eventqueue for this module
  *
@@ -232,7 +232,7 @@ void KbSetKeyRepeating(u_char Key, u_char Property)
  * \return KB_OK in case an event was found
  * \return KB_ERROR in case no event was found (return due to timeout)
  */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 int KbWaitForKeyEvent(u_long dwTimeout)
 {
 
@@ -248,7 +248,7 @@ int KbWaitForKeyEvent(u_long dwTimeout)
     return(nError);
 }
 
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 /*!
  * \brief Return the databyte that was receeived in the IR-stream
  *
@@ -260,7 +260,7 @@ int KbWaitForKeyEvent(u_long dwTimeout)
  *
  * \todo implement a key-buffer for this routine
  */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 u_char KbGetKey()
 {
     return(KeyBuffer[0]);
@@ -275,7 +275,7 @@ void KbInjectKey(u_char VirtualKey)
     KeyBuffer[0]=VirtualKey;
     NutEventPostFromIrq(&hKBEvent);   // 'valid key' detected -> generate Event
 }
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 /*!
  * \brief Initialise the Keyboard module
  *
@@ -288,7 +288,7 @@ void KbInjectKey(u_char VirtualKey)
  * when no key is pressed. Use negative logic to detect keys.
  * So default state of the colums is '1'
  */
-/* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/* ����������������������������������������������������������������������� */
 void KbInit()
 {
     u_char i;

+ 2 - 2
keyboard.h

@@ -90,14 +90,14 @@
 /* export global routines (interface)                                      */
 /*-------------------------------------------------------------------------*/
 void    KbInit(void);
-int    KbScan(void);
+void  KbScan(void);
 int 	CheckKey();
 int     KbWaitForKeyEvent(u_long);
 u_char  KbGetKey(void);
 void    KbSetKeyRepeating(u_char, u_char);
 void    KbInjectKey(u_char VirtualKey);
 
-/*  ÍÍÍÍ  End Of File  ÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ */
+/*  ����  End Of File  �������� �������������������������������������������� */
 
 
 

+ 39 - 7
main.c

@@ -225,18 +225,19 @@ int timer(time_t start){
 }
 
 int checkOffPressed(){
-    if (KbScan() < -1){
+    if (KbGetKey() > 1){
         LcdBackLight(LCD_BACKLIGHT_ON);
         return 1;
     } else {
         return 0;
     }
 }
-
+int VOL2;
 int main(void)
 {
-    initialized = 0;
+	initialized = 0;
 	time_t start;
+    time_t startVolumeTime;
 	int running = 0;
 
     WatchDogDisable();
@@ -266,6 +267,7 @@ int main(void)
     NutThreadCreate("BackgroundThread", Alarmsync, NULL, 1024);
     /** Quick fix for turning off the display after 10 seconds boot */
     start = time(0);
+    startVolumeTime = time(0);
     running = 1;
 
     RcInit();
@@ -281,7 +283,9 @@ int main(void)
 
 	/* Enable global interrupts */
 	sei();
-
+    unsigned char VOL = 64;
+    displayDate(1);
+    displayTime(0);
     for (;;)
     {
 		//Check if a button is pressed
@@ -302,15 +306,43 @@ int main(void)
         if(!isAlarmSyncing && X12RtcGetStatus(5) > 0)
         {
 			displayAlarm(0,1);
-			if (KbScan() < -1 || checkTime() == 1){
+			if (KbGetKey() < -1 || checkTime() == 1){
 				handleAlarm();
 				LcdBackLight(LCD_BACKLIGHT_OFF);
 			}
         }
         else {
-            displayTime(0);
-            displayDate(1);
+                if (timer(startVolumeTime) >= 10) {
+                    startVolumeTime = time(0);
+                    ClearLcd();
+                    displayTime(0);
+                    displayDate(1);
+                }
+            }
+
+        VOL = VOL2;
+        if(KbGetKey() == KEY_DOWN)
+        {
+            NutSleep(150);
+            startVolumeTime = time(0);
+            if(VOL > 1){
+            VOL -= 8;
+            VsSetVolume (128-VOL, 128-VOL);
+            displayVolume(VOL/8);
+                }
+        }
+        else if(KbGetKey() == KEY_UP)
+        {
+            NutSleep(150);
+            startVolumeTime = time(0);
+            if(VOL < 128) {
+                VOL += 8;
+                VsSetVolume(128-VOL, 128-VOL);
+                displayVolume(VOL/8);
+
+            }
         }
+        VOL2 = VOL;
         WatchDogRestart();
     }