Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Terminal EthernetNetIf Pachube TextLCD mbed ConfigFile FirmwareUpdater
geigercounter.h
00001 #ifndef MBED_GEIGERCOUNTER_H 00002 #define MBED_GEIGERCOUNTER_H 00003 #include "mbed.h" 00004 00005 class Geigercounter { 00006 public: 00007 Geigercounter(PinName pin,PinName spin) : _interrupt(pin),_speaker(spin),_speakerstop(){ 00008 _interrupt.rise(this, &Geigercounter::increment); 00009 00010 //speaker setup sound off 00011 _speaker.period(1.0/2000.0); 00012 _speaker=0.0; 00013 _speakeron=true; 00014 } 00015 00016 void start(){ 00017 _count=0; 00018 _starttime=time(NULL); 00019 _geigerrun=true; 00020 } 00021 00022 void stop(){ 00023 _geigerrun=false; 00024 _stoptime=time(NULL); 00025 00026 } 00027 00028 void soundon(){ 00029 _speakeron=true; 00030 } 00031 00032 void soundoff(){ 00033 _speakeron=false; 00034 } 00035 00036 00037 float getcps(); 00038 float getcpm(); 00039 00040 int read() { 00041 return _count; 00042 } 00043 00044 private: 00045 void _speakeroff(){ 00046 _speaker=0; 00047 } 00048 void increment() { 00049 if(_geigerrun){ 00050 00051 _count++; 00052 00053 //sound 00054 if(_speakeron){ 00055 _speaker=0.5; 00056 _speakerstop.attach(this,&Geigercounter::_speakeroff,0.02); 00057 } 00058 } 00059 } 00060 00061 InterruptIn _interrupt; 00062 PwmOut _speaker; 00063 Timeout _speakerstop; 00064 time_t _starttime; 00065 time_t _stoptime; 00066 volatile int _count; 00067 volatile bool _geigerrun; 00068 volatile bool _speakeron; 00069 00070 }; 00071 00072 00073 #endif
Generated on Wed Jul 13 2022 02:46:53 by
1.7.2