{"action":"created","issue":{"url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1099","labels_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1099/labels{/name}","comments_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1099/comments","events_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1099/events","html_url":"https://github.com/cleanflight/cleanflight/issues/1099","id":93992330,"number":1099,"title":"Invert Buzzer functionality CLI option","user":{"login":"ctzsnooze","id":11737748,"avatar_url":"https://avatars.githubusercontent.com/u/11737748?v=3","gravatar_id":"","url":"https://api.github.com/users/ctzsnooze","html_url":"https://github.com/ctzsnooze","followers_url":"https://api.github.com/users/ctzsnooze/followers","following_url":"https://api.github.com/users/ctzsnooze/following{/other_user}","gists_url":"https://api.github.com/users/ctzsnooze/gists{/gist_id}","starred_url":"https://api.github.com/users/ctzsnooze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ctzsnooze/subscriptions","organizations_url":"https://api.github.com/users/ctzsnooze/orgs","repos_url":"https://api.github.com/users/ctzsnooze/repos","events_url":"https://api.github.com/users/ctzsnooze/events{/privacy}","received_events_url":"https://api.github.com/users/ctzsnooze/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-07-09T08:42:12Z","updated_at":"2015-09-13T08:33:35Z","closed_at":null,"body":"I don't know how to author a pull request but this is what I'd like to achieve....\r\n\r\nWhen using the Buzzer pin to drive large clearly visible LEDs for visibility in low light, the intent is the opposite of when that buzzer pin is used to make a noise.  At night you want the inverse behaviour = lights on normally, flashing off when there's a problem.\r\n\r\nI figured out the changes required and would be very grateful if someone could help author a pull request to make them happen:\r\n\r\nAround lines 130, change the default for beeper on/off:\r\n\r\n    // Beeper off = 0 Beeper on = 1\r\n    //static uint8_t beeperIsOn = 0;  **** default\r\n    static uint8_t beeperIsOn = 1;\r\n\r\nAround 310:\r\n\r\n    // BEEP_ON; **** default\r\n    BEEP_OFF;\r\n\r\nAnd likewise a bit later around 325:\r\n\r\n    //BEEP_OFF;  **** default\r\n    BEEP_ON;  \r\n\r\nThese are the only points where the code needs reversal, so if say BUZZER_INVERT = 1 in the CLI, the uncommented (non default) behaviour shown above would apply.\r\n\r\nThis would not need to be profile based.\r\n\r\nSome beeper sound sequences are best changed a little when using them with LEDs.  They were designed for buzzers, with reasonably long 'on' times to ensure the beeps are heard.  But for LEDs we only need brief flashes off to communicate (say) low battery states, otherwise we can't see anything in the dark for the critical alarm, which must buzz all the time!  :-)\r\n\r\nA more thorough solution, matching the LED orientation of the reversed state, would also change some of the buzzer sound patterns.  For instance for low and critical battery I did this:\r\n\r\n    // low battery beep\r\n    static const uint8_t beep_lowBatteryBeep[] = {\r\n    // 25, 50, BEEPER_COMMAND_STOP   ***default\r\n    100, 4, BEEPER_COMMAND_STOP\r\n\r\n(a single very brief flash off every second when low)\r\n\r\n    // critical battery beep\r\n    static const uint8_t beep_critBatteryBeep[] = {\r\n    //50, 2, BEEPER_COMMAND_STOP  ***default\r\n    26, 4, 10, 4, BEEPER_COMMAND_STOP\r\n\r\n(two very brief flashes when battery is critical, repeated 3 times every second)\r\n\r\nObviously these patterns could change when the user selected BUZZER_INVERT = 1 in the CLI\r\n\r\nI don't know how best to code this but would be very, very grateful if someone could help implement this with me.\r\n"},"comment":{"url":"https://api.github.com/repos/cleanflight/cleanflight/issues/comments/139851629","html_url":"https://github.com/cleanflight/cleanflight/issues/1099#issuecomment-139851629","issue_url":"https://api.github.com/repos/cleanflight/cleanflight/issues/1099","id":139851629,"user":{"login":"Pierre-A","id":8274225,"avatar_url":"https://avatars.githubusercontent.com/u/8274225?v=3","gravatar_id":"","url":"https://api.github.com/users/Pierre-A","html_url":"https://github.com/Pierre-A","followers_url":"https://api.github.com/users/Pierre-A/followers","following_url":"https://api.github.com/users/Pierre-A/following{/other_user}","gists_url":"https://api.github.com/users/Pierre-A/gists{/gist_id}","starred_url":"https://api.github.com/users/Pierre-A/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Pierre-A/subscriptions","organizations_url":"https://api.github.com/users/Pierre-A/orgs","repos_url":"https://api.github.com/users/Pierre-A/repos","events_url":"https://api.github.com/users/Pierre-A/events{/privacy}","received_events_url":"https://api.github.com/users/Pierre-A/received_events","type":"User","site_admin":false},"created_at":"2015-09-13T08:33:35Z","updated_at":"2015-09-13T08:33:35Z","body":"Yes for the first part but the Naze board is a specific case as seen in lines 281-286 of main.c. \r\nFor newer revision (5 and above) the *isInverted* parameter is *true* due to a NPN driving transistor (2N3904) on the buzzer output (previously was OD for a 2N3906). \r\nSo, you should only fix it to *false* instead of *true* on line 285 and it should be fine."}}