Browse Source

Merge pull request #4506 from thinkyhead/rc_buzzer_needs_beeper

Buzzer requires BEEPER_PIN
Scott Lahteine 8 years ago
parent
commit
fbd8f06951
6 changed files with 30 additions and 26 deletions
  1. 1
    2
      Marlin/Marlin.h
  2. 14
    13
      Marlin/Marlin_main.cpp
  3. 4
    0
      Marlin/buzzer.h
  4. 1
    1
      Marlin/pins_AZTEEG_X3.h
  5. 9
    9
      Marlin/ultralcd.cpp
  6. 1
    1
      Marlin/ultralcd.h

+ 1
- 2
Marlin/Marlin.h View File

384
 void calculate_volumetric_multipliers();
384
 void calculate_volumetric_multipliers();
385
 
385
 
386
 // Buzzer
386
 // Buzzer
387
-#if HAS_BUZZER
387
+#if HAS_BUZZER && PIN_EXISTS(BEEPER)
388
   #include "buzzer.h"
388
   #include "buzzer.h"
389
-  extern Buzzer buzzer;
390
 #endif
389
 #endif
391
 
390
 
392
 /**
391
 /**

+ 14
- 13
Marlin/Marlin_main.cpp View File

373
   Stopwatch print_job_timer = Stopwatch();
373
   Stopwatch print_job_timer = Stopwatch();
374
 #endif
374
 #endif
375
 
375
 
376
-// Buzzer
377
-#if HAS_BUZZER
378
-    Buzzer buzzer;
376
+// Buzzer - I2C on the LCD or a BEEPER_PIN
377
+#if ENABLED(LCD_USE_I2C_BUZZER)
378
+  #define BUZZ(d,f) lcd_buzz(d, f)
379
+#elif HAS_BUZZER
380
+  Buzzer buzzer;
381
+  #define BUZZ(d,f) buzzer.tone(d, f)
382
+#else
383
+  #define BUZZ(d,f) NOOP
379
 #endif
384
 #endif
380
 
385
 
381
 static uint8_t target_extruder;
386
 static uint8_t target_extruder;
5657
     // Limits the tone duration to 0-5 seconds.
5662
     // Limits the tone duration to 0-5 seconds.
5658
     NOMORE(duration, 5000);
5663
     NOMORE(duration, 5000);
5659
 
5664
 
5660
-    buzzer.tone(duration, frequency);
5665
+    BUZZ(duration, frequency);
5661
   }
5666
   }
5662
 
5667
 
5663
 #endif // HAS_BUZZER
5668
 #endif // HAS_BUZZER
6129
         SERIAL_ERROR_START;
6134
         SERIAL_ERROR_START;
6130
         SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR);
6135
         SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR);
6131
         LCD_ALERTMESSAGEPGM("Err: Too far!");
6136
         LCD_ALERTMESSAGEPGM("Err: Too far!");
6132
-        #if HAS_BUZZER
6133
-          buzzer.tone(200, 40);
6134
-        #endif
6137
+        BUZZ(200, 40);
6135
         err = true;
6138
         err = true;
6136
         break;
6139
         break;
6137
       }
6140
       }
6142
     SYNC_PLAN_POSITION_KINEMATIC();
6145
     SYNC_PLAN_POSITION_KINEMATIC();
6143
     report_current_position();
6146
     report_current_position();
6144
     LCD_MESSAGEPGM(MSG_HOME_OFFSETS_APPLIED);
6147
     LCD_MESSAGEPGM(MSG_HOME_OFFSETS_APPLIED);
6145
-    #if HAS_BUZZER
6146
-      buzzer.tone(200, 659);
6147
-      buzzer.tone(200, 698);
6148
-    #endif
6148
+    BUZZ(200, 659);
6149
+    BUZZ(200, 698);
6149
   }
6150
   }
6150
 }
6151
 }
6151
 
6152
 
6327
       #if HAS_BUZZER
6328
       #if HAS_BUZZER
6328
         millis_t ms = millis();
6329
         millis_t ms = millis();
6329
         if (ms >= next_tick) {
6330
         if (ms >= next_tick) {
6330
-          buzzer.tone(300, 2000);
6331
+          BUZZ(300, 2000);
6331
           next_tick = ms + 2500; // Beep every 2.5s while waiting
6332
           next_tick = ms + 2500; // Beep every 2.5s while waiting
6332
         }
6333
         }
6333
       #endif
6334
       #endif
8470
     print_job_timer.tick();
8471
     print_job_timer.tick();
8471
   #endif
8472
   #endif
8472
 
8473
 
8473
-  #if HAS_BUZZER
8474
+  #if HAS_BUZZER && PIN_EXISTS(BEEPER)
8474
     buzzer.tick();
8475
     buzzer.tick();
8475
   #endif
8476
   #endif
8476
 }
8477
 }

+ 4
- 0
Marlin/buzzer.h View File

27
 #include "circularqueue.h"
27
 #include "circularqueue.h"
28
 #include "temperature.h"
28
 #include "temperature.h"
29
 
29
 
30
+#include "MarlinConfig.h"
31
+
30
 #define TONE_QUEUE_LENGTH 4
32
 #define TONE_QUEUE_LENGTH 4
31
 
33
 
32
 /**
34
 /**
135
     }
137
     }
136
 };
138
 };
137
 
139
 
140
+extern Buzzer buzzer;
141
+
138
 #endif
142
 #endif

+ 1
- 1
Marlin/pins_AZTEEG_X3.h View File

30
 
30
 
31
 #define BOARD_NAME "Azteeg X3"
31
 #define BOARD_NAME "Azteeg X3"
32
 
32
 
33
-#include "pins_RAMPS.h"
33
+#include "pins_RAMPS_13.h"
34
 
34
 
35
 #if ENABLED(VIKI2) || ENABLED(miniVIKI)
35
 #if ENABLED(VIKI2) || ENABLED(miniVIKI)
36
 
36
 

+ 9
- 9
Marlin/ultralcd.cpp View File

1074
             lcd_return_to_status();
1074
             lcd_return_to_status();
1075
             //LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
1075
             //LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
1076
             #if HAS_BUZZER
1076
             #if HAS_BUZZER
1077
-              buzzer.tone(200, 659);
1078
-              buzzer.tone(200, 698);
1077
+              lcd_buzz(200, 659);
1078
+              lcd_buzz(200, 698);
1079
             #endif
1079
             #endif
1080
           }
1080
           }
1081
           else {
1081
           else {
2342
    * Audio feedback for controller clicks
2342
    * Audio feedback for controller clicks
2343
    *
2343
    *
2344
    */
2344
    */
2345
-
2346
-  #if ENABLED(LCD_USE_I2C_BUZZER)
2347
-    void lcd_buzz(long duration, uint16_t freq) { // called from buzz() in Marlin_main.cpp where lcd is unknown
2345
+  void lcd_buzz(long duration, uint16_t freq) {
2346
+    #if ENABLED(LCD_USE_I2C_BUZZER)
2348
       lcd.buzz(duration, freq);
2347
       lcd.buzz(duration, freq);
2349
-    }
2350
-  #endif
2348
+    #elif PIN_EXISTS(BEEPER)
2349
+      buzzer.tone(duration, freq);
2350
+    #endif
2351
+  }
2351
 
2352
 
2352
   void lcd_quick_feedback() {
2353
   void lcd_quick_feedback() {
2353
     lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
2354
     lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
2354
     next_button_update_ms = millis() + 500;
2355
     next_button_update_ms = millis() + 500;
2355
 
2356
 
2356
     // Buzz and wait. The delay is needed for buttons to settle!
2357
     // Buzz and wait. The delay is needed for buttons to settle!
2358
+    lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
2357
     #if ENABLED(LCD_USE_I2C_BUZZER)
2359
     #if ENABLED(LCD_USE_I2C_BUZZER)
2358
-      lcd.buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
2359
       delay(10);
2360
       delay(10);
2360
     #elif PIN_EXISTS(BEEPER)
2361
     #elif PIN_EXISTS(BEEPER)
2361
-      buzzer.tone(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
2362
       for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
2362
       for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
2363
     #endif
2363
     #endif
2364
   }
2364
   }

+ 1
- 1
Marlin/ultralcd.h View File

43
   void lcd_kill_screen();
43
   void lcd_kill_screen();
44
   void kill_screen(const char* lcd_msg);
44
   void kill_screen(const char* lcd_msg);
45
 
45
 
46
-  #if ENABLED(LCD_USE_I2C_BUZZER)
46
+  #if HAS_BUZZER
47
     void lcd_buzz(long duration, uint16_t freq);
47
     void lcd_buzz(long duration, uint16_t freq);
48
   #endif
48
   #endif
49
 
49
 

Loading…
Cancel
Save