Le forum français des radios OpenTX ou FrOS
Le forum français des radios OpenTX ou FrOS
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Le deal à ne pas rater :
Cdiscount : -30€ dès 300€ d’achat sur une sélection Apple
Voir le deal

Benedini sound module

2 participants

Aller en bas

Benedini sound module Empty Benedini sound module

Message par thetux Mer 11 Aoû 2021 - 0:20

Salut,

sur un module son Benedini, il existe plusieurs possibilités, dont une consiste à remplacer une des voies par un potentiometre rotatif à 12 positions et un bouton. L'idée, c'est de remplacer ce bouton hardware par un script lua de mixage, et un widget lua pour afficher le son à jouer. Perso, j'utilise S1 pour choisir le son, et SH pour le jouer, mais c'est paramétrable.

On enregistre le script benedini.lua, situé dans SCRIPTS/MIXES/ , dans les custom scripts:
Benedini sound module Screen10

On peut alors l'utiliser dans les mixages:
Benedini sound module Screen11

Et enfin, main.lua, situé dans WIDGETS/Benedini/ peut être affiché dans la bare des widget du haut. On doit cependant choisir aussi à cet endroit le trigger et la source, car le widget et le mixage sont en fait indépendants.
Benedini sound module Screen12

main.lua:
Code:

---- #########################################################################
---- #                                                                       #
---- # Copyright (C) Nicolas Seinlet                                         #
---- #                                                                       #
---- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html               #
---- #                                                                       #
---- # This program is free software; you can redistribute it and/or modify  #
---- # it under the terms of the GNU General Public License version 2 as     #
---- # published by the Free Software Foundation.                            #
---- #                                                                       #
---- # This program is distributed in the hope that it will be useful        #
---- # but WITHOUT ANY WARRANTY; without even the implied warranty of        #
---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
---- # GNU General Public License for more details.                          #
---- #                                                                       #
---- #########################################################################

local options = {
  { "soundsource", SOURCE, 1 },
  { "soundtrigger", SOURCE, 1 },
}

local function create(zone, options)
  local wgt  = { zone=zone, options=options}
  return wgt
end

local function update(wgt, options)
  wgt.options = options
end

local function background(wgt)
  return
end

function refresh(wgt)
   local val = getValue(wgt.options.soundsource);
   -- #100/88/76/64/52/40/28/16/0
   if getValue(wgt.options.soundtrigger) > 0 then
     lcd.setColor(TEXT_COLOR, RED)
   else
     lcd.setColor(TEXT_COLOR, BLACK)
   end
    if val < -900 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "Start", TEXT_COLOR+BOLD)
    elseif val < -820 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "Horn", TEXT_COLOR+BOLD)
    elseif val < -700 then
        lcd.drawText(wgt.zone.x+5, wgt.zone.y+1, "Open", TEXT_COLOR+BOLD)
        lcd.drawText(wgt.zone.x+5, wgt.zone.y+15, "door", TEXT_COLOR+BOLD)
    elseif val < -580 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+1, "Close", TEXT_COLOR+BOLD)
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+15, "door", TEXT_COLOR+BOLD)
    elseif val < -460 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "Roof", TEXT_COLOR+BOLD)
    elseif val < -340 then
        lcd.drawText(wgt.zone.x+5, wgt.zone.y+1, "Start", TEXT_COLOR+BOLD)
        lcd.drawText(wgt.zone.x+5, wgt.zone.y+15, "GPS", TEXT_COLOR+BOLD)
    elseif val < -220 then
        lcd.drawText(wgt.zone.x+5, wgt.zone.y+1, "Align", TEXT_COLOR+BOLD)
        lcd.drawText(wgt.zone.x+5, wgt.zone.y+15, "GPS", TEXT_COLOR+BOLD)
    elseif val < -100 then
        lcd.drawText(wgt.zone.x+5, wgt.zone.y+1, "Stop", TEXT_COLOR+BOLD)
        lcd.drawText(wgt.zone.x+5, wgt.zone.y+15, "GPS", TEXT_COLOR+BOLD)
    elseif val > 900 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "V +", TEXT_COLOR+BOLD)
    elseif val > 820 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "V -", TEXT_COLOR+BOLD)
    elseif val > 700 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "Inter", TEXT_COLOR+BOLD)
    elseif val > 580 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "S12", TEXT_COLOR+BOLD)
    elseif val > 460 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "S11", TEXT_COLOR+BOLD)
    elseif val > 340 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "S10", TEXT_COLOR+BOLD)
    elseif val > 220 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "S09", TEXT_COLOR+BOLD)
    elseif val > 100 then
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "S08", TEXT_COLOR+BOLD)
    else
       lcd.drawText(wgt.zone.x+5, wgt.zone.y+5, "", BLACK+BOLD)
    end
    lcd.setColor(TEXT_COLOR, BLACK)
end

return { name="Benedini", options=options, create=create, update=update, refresh=refresh, background=background }

benedini.lua:
Code:

---- #########################################################################
---- #                                                                       #
---- # Copyright (C) Nicolas Seinlet                                         #
---- #                                                                       #
---- # License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html               #
---- #                                                                       #
---- # This program is free software; you can redistribute it and/or modify  #
---- # it under the terms of the GNU General Public License version 2 as     #
---- # published by the Free Software Foundation.                            #
---- #                                                                       #
---- # This program is distributed in the hope that it will be useful        #
---- # but WITHOUT ANY WARRANTY; without even the implied warranty of        #
---- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
---- # GNU General Public License for more details.                          #
---- #                                                                       #
---- #########################################################################
local P={}

P.input =
 {
 { "sound-in", SOURCE,},
 }

P.output =
  {"to-play",
  }

-- periodically called function
P.run=function(sound)

    if sound < -900 then
       return -1024
    elseif sound < -820 then
       return -901
    elseif sound < -700 then
       return -778
    elseif sound < -580 then
       return -655
    elseif sound < -460 then
       return -532
    elseif sound < -340 then
       return -410
    elseif sound < -220 then
       return -287
    elseif sound < -100 then
       return -164
    elseif sound > 900 then
       return 1024
    elseif sound > 820 then
       return 901
    elseif sound > 700 then
       return 778
    elseif sound > 580 then
       return 655
    elseif sound > 460 then
       return 532
    elseif sound > 340 then
       return 410
    elseif sound > 220 then
       return 287
    elseif sound > 100 then
       return 164
    else
       return 0
    end
end

return P

J'espère que cela pourrait vous être utile,

Nicolas.
thetux
thetux

Masculin Messages : 106
Date d'inscription : 20/12/2014
Localisation : Andenne (B)

Revenir en haut Aller en bas

Benedini sound module Empty Re: Benedini sound module

Message par CoyotteDundee Ven 13 Aoû 2021 - 15:04

Merci pour cette chouette contribution !

Coyotte

_________________

... the alien anthropologists admitted they were still perplexed.
But on eliminating every other reason for our sad demise, they logged the only explanation left :
This species has amused itself to death...
                                                                                                                                    (R. Waters)

Pas de support par MP ! Nous sommes sur un forum pour échanger publiquement.
CoyotteDundee
CoyotteDundee
Administrateur

Masculin Messages : 5886
Date d'inscription : 03/03/2014
Age : 60
Localisation : Montegnée (Liège)

Revenir en haut Aller en bas

Revenir en haut

- Sujets similaires

 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum