アナログポート から スイッチを3つ認識するライブラリです。 6つのアナログポートを同時に認識して、18個のSWまで認識できます。

Dependents:   kitchenTimer LPC1114FN28_kitchenTimer_Clock

Embed: (wiki syntax)

« Back to documentation index

SwAnalog Class Reference

SwAnalog Class Reference

SWANALOG control class, based on a "mbed function". More...

#include <SwAnalog.h>

Public Types

enum  
 

SW Number call name.

More...

Public Member Functions

 SwAnalog (PinName adinput0=NC, PinName adinput1=NC, PinName adinput2=NC, PinName adinput3=NC, PinName adinput4=NC, PinName adinput5=NC)
 Create a sw analog input object connected to the specified analog Input pin.
void refreshEdgeData (void)
 refresh edge data
uint8_t checkEdgeOn (uint8_t swNo)
 Check Off to On edge.
uint8_t checkEdgeOff (uint8_t swNo)
 Check On to Off edge.
uint8_t checkLevel (uint8_t swNo)
 Check sw Level.

Detailed Description

SWANALOG control class, based on a "mbed function".

Example:

 // *******************************************************************
 // SwAnalogInput Library example program
 //  mbed no analog port de 3hon no sw wo ninsiki suru.
 //  6hon no analog port (p15 - p20) de 6 * 3 = 18 ko no sw ninsiki ga dekiru.
 //
 // <schematic>
 //   -.- mbed VOUT(+3.3[V])
 //    |                                               |--------------------> mbed p20(ADinput)
 //    |   ---------       ---------       ---------   |   ---------
 //    .---| Rsw2  |---.---| Rsw1  |---.---| Rsw0  |---.---| Rout  |----|
 //    |   ---------   |   ---------   |   ---------   |   ---------    |
 //    |     ----      |     -----     |     -----     |                |
 //    |-----o  o------.-----o  o------.-----o  o------|              -----
 //           SW2            SW1              SW0                      mbed GND(0[V])
 // 
 //  Rsw2 : 8.2[kohm], Rsw1 = 3.9[kohm], Rsw0 = 2.0[kohm], Rout = 1.0[kohm] (R no seido ha +-1[%])
 //
 // <program no naiyo>
 //  mbed LED1 : sw0 no level de tento  sw Off = led Off, sw On = led On
 //  mbed LED2 : sw1 no level de tento  sw Off = led Off, sw On = led On
 //  mbed LED3 : sw2 no level de tento  sw Off = led Off, sw On = led On
 //  mbed LED4 : sw0,sw1,sw2 no Off kara On henka de led tento jotai wo hanten.
 //
 // 
 // <rireki>
 // 2012/02/12 : syohan
 // *********************************************************************

 #include "mbed.h"
 #include "SwAnalog.h"

 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
 DigitalOut led3(LED3);
 DigitalOut led4(LED4);

 SwAnalog sw(p20);  // p20(adinput) :sw0,sw1,sw2
                   
 int main() {
     while(1) {
         // sw level and edge data refresh
         sw.refreshEdgeData();
         
         // tact action (sw0 level = on : led1 = on)
         led1 = sw.checkLevel(0);
         
         // tact action (sw1 level = off : led2 = on)
         led2 = sw.checkLevel(1);
         
         // tact action (sw2 level = off : led3 = on)
         led3 = sw.checkLevel(2);
         
         // toggle action (sw0 to sw3 level Off to On : led4 invert )
         if((sw.checkEdgeOn(0) == 1)   // sw0
         || (sw.checkEdgeOn(1) == 1)   // sw1
         || (sw.checkEdgeOn(2) == 1)   // sw2
         ){
              led4 = !led4;
         }
     }
 }

Definition at line 105 of file SwAnalog.h.


Member Enumeration Documentation

anonymous enum

SW Number call name.

Parameters:
adinput0: Z_sw1 to Z_sw3
adinput1: Z_sw4 to Z_sw6
....
adinput5: Z_sw16 tp Z_sw18

Definition at line 169 of file SwAnalog.h.


Constructor & Destructor Documentation

SwAnalog ( PinName  adinput0 = NC,
PinName  adinput1 = NC,
PinName  adinput2 = NC,
PinName  adinput3 = NC,
PinName  adinput4 = NC,
PinName  adinput5 = NC 
)

Create a sw analog input object connected to the specified analog Input pin.

Parameters:
PinNameadinput0 : analog input pin(pin15 to pin20) : sw0 kara sw2 no ninsiki
PinNameadinput1 : analog input pin(pin15 to pin20) : sw3 kara sw5 no ninsiki
PinNameadinput2 : analog input pin(pin15 to pin20) : sw6 kara sw8 no ninsiki
PinNameadinput3 : analog input pin(pin15 to pin20) : sw9 kara sw11 no ninsiki
PinNameadinput4 : analog input pin(pin15 to pin20) : sw12 kara sw14 no ninsiki
PinNameadinput5 : analog input pin(pin15 to pin20) : sw15 kara sw17 no ninsiki

Recognition of the SW period is 10ms

Definition at line 16 of file SwAnalog.cpp.


Member Function Documentation

uint8_t checkEdgeOff ( uint8_t  swNo )

Check On to Off edge.

Parameters:
uint8_tswNo : 0:sw0, 1:sw1, ... ,17:sw17
returnuint8_t Off edge check 0 : Nasi 1 : Ari

Definition at line 180 of file SwAnalog.cpp.

uint8_t checkEdgeOn ( uint8_t  swNo )

Check Off to On edge.

Parameters:
uint8_tswNo : 0:sw0, 1:sw1, ... ,17:sw17
returnuint8_t On edge check 0: edge Nasi 1: edge Ari

Definition at line 167 of file SwAnalog.cpp.

uint8_t checkLevel ( uint8_t  swNo )

Check sw Level.

Parameters:
uint8_tswNo : 0:sw0, 1:sw1, ... ,17:sw17
returnuint8_t sw level check 0 : Off 1 : On

Definition at line 193 of file SwAnalog.cpp.

void refreshEdgeData ( void   )

refresh edge data

Parameters:
none
returnnone

main de edge data wo tukau maeni jiko suru

Definition at line 150 of file SwAnalog.cpp.