Parcourir la source

Add lcd_buzz function to ultralcd.h so that non-LCD code can make use of lcd's buzzer.

Argument order of lcd_buzz was set to mirror that on tone(). Change
default M300 frequency to something audible.
Robert F-C il y a 12 ans
Parent
révision
7f57f28ccc
3 fichiers modifiés avec 23 ajouts et 7 suppressions
  1. 13
    7
      Marlin/Marlin_main.cpp
  2. 7
    0
      Marlin/ultralcd.cpp
  3. 3
    0
      Marlin/ultralcd.h

+ 13
- 7
Marlin/Marlin_main.cpp Voir le fichier

1446
     }
1446
     }
1447
     break;
1447
     break;
1448
     
1448
     
1449
-    #if defined(LARGE_FLASH) && LARGE_FLASH == true && defined(BEEPER) && BEEPER > -1
1449
+    #if defined(LARGE_FLASH) && LARGE_FLASH == true
1450
     case 300: // M300
1450
     case 300: // M300
1451
     {
1451
     {
1452
-      int beepS = 1;
1452
+      int beepS = 400;
1453
       int beepP = 1000;
1453
       int beepP = 1000;
1454
       if(code_seen('S')) beepS = code_value();
1454
       if(code_seen('S')) beepS = code_value();
1455
       if(code_seen('P')) beepP = code_value();
1455
       if(code_seen('P')) beepP = code_value();
1456
-      tone(BEEPER, beepS);
1457
-      delay(beepP);
1458
-      noTone(BEEPER);
1456
+      #if defined(BEEPER) && BEEPER > -1
1457
+        tone(BEEPER, beepS);
1458
+        delay(beepP);
1459
+        noTone(BEEPER);
1460
+      #elif defined(ULTRALCD)
1461
+        lcd_buzz(beepS, beepP);
1462
+      #endif
1459
     }
1463
     }
1460
     break;
1464
     break;
1461
     #endif // M300
1465
     #endif // M300
1672
           manage_inactivity();
1676
           manage_inactivity();
1673
           lcd_update();
1677
           lcd_update();
1674
           
1678
           
1675
-          #if BEEPER > -1
1676
           if(cnt==0)
1679
           if(cnt==0)
1677
           {
1680
           {
1681
+          #if defined(BEEPER) && BEEPER > -1
1678
             SET_OUTPUT(BEEPER);
1682
             SET_OUTPUT(BEEPER);
1679
             
1683
             
1680
             WRITE(BEEPER,HIGH);
1684
             WRITE(BEEPER,HIGH);
1681
             delay(3);
1685
             delay(3);
1682
             WRITE(BEEPER,LOW);
1686
             WRITE(BEEPER,LOW);
1683
             delay(3);
1687
             delay(3);
1684
-          }
1688
+          #else 
1689
+            lcd_buzz(1000/6,100);
1685
           #endif
1690
           #endif
1691
+          }
1686
         }
1692
         }
1687
         
1693
         
1688
         //return to normal
1694
         //return to normal

+ 7
- 0
Marlin/ultralcd.cpp Voir le fichier

946
     lastEncoderBits = enc;
946
     lastEncoderBits = enc;
947
 }
947
 }
948
 
948
 
949
+void lcd_buzz(long duration, uint16_t freq)
950
+{ 
951
+#ifdef LCD_USE_I2C_BUZZER
952
+  lcd.buzz(duration,freq);
953
+#endif   
954
+}
955
+
949
 bool lcd_clicked() 
956
 bool lcd_clicked() 
950
 { 
957
 { 
951
   return LCD_CLICKED;
958
   return LCD_CLICKED;

+ 3
- 0
Marlin/ultralcd.h Voir le fichier

34
   extern int absPreheatHPBTemp;
34
   extern int absPreheatHPBTemp;
35
   extern int absPreheatFanSpeed;
35
   extern int absPreheatFanSpeed;
36
     
36
     
37
+  void lcd_buzz(long duration,uint16_t freq);
38
+
37
   bool lcd_clicked();
39
   bool lcd_clicked();
38
 
40
 
39
 #else //no lcd
41
 #else //no lcd
42
   FORCE_INLINE void lcd_setstatus(const char* message) {}
44
   FORCE_INLINE void lcd_setstatus(const char* message) {}
43
   FORCE_INLINE void lcd_buttons_update() {}
45
   FORCE_INLINE void lcd_buttons_update() {}
44
   FORCE_INLINE void lcd_reset_alert_level() {}
46
   FORCE_INLINE void lcd_reset_alert_level() {}
47
+  FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
45
 
48
 
46
   #define LCD_MESSAGEPGM(x) 
49
   #define LCD_MESSAGEPGM(x) 
47
   #define LCD_ALERTMESSAGEPGM(x) 
50
   #define LCD_ALERTMESSAGEPGM(x) 

Chargement…
Annuler
Enregistrer