SlideShare a Scribd company logo
1 of 29
Download to read offline
Using StateCharts on small electronic
devices; for fun, profit and numbats
Harry McNally, Decisions and Designs, BarCamp Perth 2009
Harry McNally, Decisions and Designs, 2009
Images: Department of Premier and Cabinet   Harry McNally, Decisions and Designs, 2009
International Union for Conservation of Nature
         and Natural Resources (IUCN)
         Red List of Threatened Species
                                                                In 2008




                          Photo by Gnangarra ... commons.wikimedia.org
                          Conservation Status Graphics by Peter Halasz




Photo by Aaron Siirila
                                       Harry McNally, Decisions and Designs, 2009
Harry McNally, Decisions and Designs, 2009
http://www.numbat.org.au/


                   Harry McNally, Decisions and Designs, 2009
Harry McNally, Decisions and Designs, 2009
Harry McNally, Decisions and Designs, 2009
Harry McNally, Decisions and Designs, 2009
Harry McNally, Decisions and Designs, 2009
Harry McNally, Decisions and Designs, 2009
Storyboard

Panel 1. Setup the camera and to standby
Tony arrives at an observation site at early twilight and
positions the video camera at the hollow log. He turns
the camera on and checks that it is viewing correctly.
He sets the camera to standby.




                                     Harry McNally, Decisions and Designs, 2009
Storyboard

Panel 2. Adjust the clock time if required
Tony checks the clock time on numbatcam and, if it needs
adjustment, he presses and holds the Select button and
uses Up and Down buttons to adjust the clock time minute
by minute. If he holds the Up or Down button for a second
the time increments automatically; slowly at first and
quickly after 6 seconds to allow simple hours adjustment.
Tony releases the Select button once the clock time is
correctly set and the start time displays. If the clock
time did not need adjustment, Tony simply presses and
releases the Select button to display the start time.


                                    Harry McNally, Decisions and Designs, 2009
Storyboard

Panel 3. Adjust the start time if required
Tony checks the start time on numbatcam and, if it needs
adjustment, he presses the Up and Down buttons to adjust
the clock time minute by minute. If he holds the Up or
Down button for one second the time changes
automatically; slowly at first and quickly after 6 seconds
to allow simple hours adjustment. Once the start time is
correct Tony presses and releases the Select button to
return to the clock time. The starter is now armed and
this is shown by a flashing asterisk instead of a flashing
cursor.


                                     Harry McNally, Decisions and Designs, 2009
Storyboard

Panel 4. Test the camera start/stop manually
Tony presses the numbatcam Manual button to send a
Start/Stop (IR remote) message to the camera. He checks
that the camera has started and presses the Manual button
again to return the camera to standby.




                                    Harry McNally, Decisions and Designs, 2009
Storyboard

Panel 5. Numbats!
Tony returns the next morning and stops and retrieves
the camera for viewing and analysis.




                                    Harry McNally, Decisions and Designs, 2009
Harry McNally, Decisions and Designs, 2009
Existing hardware ?




AVR Butterfly
http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3146

                                        Harry McNally, Decisions and Designs, 2009
Small efficient state code ?
http://www.state-machine.com/




http://www.state-machine.com/psicc2/index.htm#Errata
http://www.state-machine.com/avr/QDKn_AVR-GNU.pdf

                                   Harry McNally, Decisions and Designs, 2009
Button
                                   Driver


 Event     Event   Event
 queue     queue   queue




   IR      Alarm
Transmit   Clock   UI Task
  Task     Task



                        Harry McNally, Decisions and Designs, 2009
Harry McNally, Decisions and Designs, 2009
static QState UI_displayTime(UI *me) {

    switch (Q_SIG(me)) {

        case Q_ENTRY_SIG : {
            QActive_post((QActive *)&AO_alarmClock, DISPLAY_TIME_SIG);
            return Q_HANDLED();
        }

        case SELECT_BUTTON_PRESS_SIG : {
            return Q_TRAN(&UI_setTime);
        }

        case MANUAL_BUTTON_PRESS_SIG : {
            QActive_post((QActive *)&AO_IR, IR_TRANSMIT_SIG);
            return Q_HANDLED();
        }
    }

    return Q_SUPER(&QHsm_top);
}

                                             Harry McNally, Decisions and Designs, 2009
static Qstate UI_setTime(UI *me) {

     switch (Q_SIG(me)) {
        case UP_BUTTON_PRESS_SIG : {
             return Q_TRAN(&UI_incrementTime);
        }
        case DOWN_BUTTON_PRESS_SIG : {
             return Q_TRAN(&UI_decrementTime);
        }
        case SELECT_BUTTON_RELEASE_SIG : {
             return Q_TRAN(&UI_setAlarm);
        }
        case UP_BUTTON_RELEASE_SIG : {
             return Q_TRAN(&UI_setTime);
        }
        case DOWN_BUTTON_RELEASE_SIG : {
             return Q_TRAN(&UI_setTime);
        }
    }

    return Q_SUPER(&UI_displayTime);
}

                                            Harry McNally, Decisions and Designs, 2009
static QState UI_incrementTime(UI *me) {

    switch (Q_SIG(me)) {

       case Q_ENTRY_SIG : {
           QActive_post((QActive *)&AO_alarmClock, INCREMENT_SIG);
           QActive_arm((QActive *)me, SET_HOLD);
           return Q_HANDLED();
       }

       case Q_EXIT_SIG : {
           QActive_disarm((QActive *)me);
           return Q_HANDLED();
       }

       case Q_TIMEOUT_SIG : {
           return Q_TRAN(&UI_autoIncrementTimeSlow);
       }
    }
    return Q_SUPER(&UI_setTime);
}

                                            Harry McNally, Decisions and Designs, 2009
static QState UI_autoIncrementTimeSlow(UI *me) {

    switch (Q_SIG(me)) {

        case Q_ENTRY_SIG : {
            QActive_post((QActive *)&AO_alarmClock, INCREMENT_SIG);
            QActive_arm((QActive *)me, SET_SLOW_REPEAT);
            me->repeatCount = 0;
            return Q_HANDLED();
        }
        case Q_TIMEOUT_SIG : {
            QActive_post((QActive *)&AO_alarmClock, INCREMENT_SIG);
            QActive_arm((QActive *)me, SET_SLOW_REPEAT);
            me->repeatCount++;
            if (me->repeatCount >= SLOW_REPEAT_COUNT) {
                 return Q_TRAN(&UI_autoIncrementTimeFast);
            }
            return Q_HANDLED();
        }
    }

    return Q_SUPER(&UI_incrementTime);
}
                                              Harry McNally, Decisions and Designs, 2009
static QState UI_autoIncrementTimeFast(UI *me) {

    switch (Q_SIG(me)) {
        case Q_ENTRY_SIG : {
            QActive_post((QActive *)&AO_alarmClock, INCREMENT_SIG);
            QActive_arm((QActive *)me, SET_FAST_REPEAT);
            return Q_HANDLED();
        }
        case Q_TIMEOUT_SIG : {
            QActive_post((QActive *)&AO_alarmClock, INCREMENT_SIG);
            QActive_arm((QActive *)me, SET_FAST_REPEAT);
            return Q_HANDLED();
        }
    }

    return Q_SUPER(&UI_incrementTime);
}



                                             Harry McNally, Decisions and Designs, 2009
From the AVR Studio build:
----------------
Device: atmega169p

Program: 5192 bytes (31.7% Full)
(.text + .data + .bootloader)

Data:      51 bytes (5.0% Full)
(.data + .bss + .noinit)
                       Harry McNally, Decisions and Designs, 2009
Questions ?




              Harry McNally, Decisions and Designs, 2009
http://www.numbat.org.au/


           http://www.state-machine.com/
http://www.state-machine.com/psicc2/index.htm#Errata
http://www.state-machine.com/avr/QDKn_AVR-GNU.pdf


          AVR Butterfly

http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3146

                                       Harry McNally, Decisions and Designs, 2009

More Related Content

Viewers also liked

Thuật ngữ quản trị nhân sự
Thuật ngữ quản trị nhân sựThuật ngữ quản trị nhân sự
Thuật ngữ quản trị nhân sựHà Văn Tuấn
 
Book weekpp2
Book weekpp2Book weekpp2
Book weekpp2ictteam
 
Tips for Chiropractors (DGC 2010)
Tips for Chiropractors (DGC 2010)Tips for Chiropractors (DGC 2010)
Tips for Chiropractors (DGC 2010)Matt
 
Spc ejercicio 9 pernos
Spc ejercicio 9 pernosSpc ejercicio 9 pernos
Spc ejercicio 9 pernosMennys-SPC-UTT
 
Masjid Sultan 28 3 09[Slideshare]
Masjid Sultan 28 3 09[Slideshare]Masjid Sultan 28 3 09[Slideshare]
Masjid Sultan 28 3 09[Slideshare]Zhulkeflee Ismail
 
2012-I 3E+1 アイディアプランコンテスト ver.1.0
2012-I 3E+1 アイディアプランコンテスト ver.1.02012-I 3E+1 アイディアプランコンテスト ver.1.0
2012-I 3E+1 アイディアプランコンテスト ver.1.010
 
Music k
Music kMusic k
Music ktabor1
 
Analysis of J cole crooked smile video
Analysis of J cole crooked smile videoAnalysis of J cole crooked smile video
Analysis of J cole crooked smile videoJAMALPG
 
0514 luke 1412 they may invite you back power point church sermon
0514 luke 1412 they may invite you back power point church sermon0514 luke 1412 they may invite you back power point church sermon
0514 luke 1412 they may invite you back power point church sermonPowerPoint_Sermons
 
Majournee ainoa
Majournee ainoaMajournee ainoa
Majournee ainoamasperez
 
Joe Vitale - Lesson4
Joe Vitale - Lesson4Joe Vitale - Lesson4
Joe Vitale - Lesson4BarryLee2016
 

Viewers also liked (16)

Thuật ngữ quản trị nhân sự
Thuật ngữ quản trị nhân sựThuật ngữ quản trị nhân sự
Thuật ngữ quản trị nhân sự
 
Su182 1998
Su182 1998Su182 1998
Su182 1998
 
Book weekpp2
Book weekpp2Book weekpp2
Book weekpp2
 
Tips for Chiropractors (DGC 2010)
Tips for Chiropractors (DGC 2010)Tips for Chiropractors (DGC 2010)
Tips for Chiropractors (DGC 2010)
 
Spc ejercicio 9 pernos
Spc ejercicio 9 pernosSpc ejercicio 9 pernos
Spc ejercicio 9 pernos
 
Masjid Sultan 28 3 09[Slideshare]
Masjid Sultan 28 3 09[Slideshare]Masjid Sultan 28 3 09[Slideshare]
Masjid Sultan 28 3 09[Slideshare]
 
2012-I 3E+1 アイディアプランコンテスト ver.1.0
2012-I 3E+1 アイディアプランコンテスト ver.1.02012-I 3E+1 アイディアプランコンテスト ver.1.0
2012-I 3E+1 アイディアプランコンテスト ver.1.0
 
Music k
Music kMusic k
Music k
 
Analysis of J cole crooked smile video
Analysis of J cole crooked smile videoAnalysis of J cole crooked smile video
Analysis of J cole crooked smile video
 
0514 luke 1412 they may invite you back power point church sermon
0514 luke 1412 they may invite you back power point church sermon0514 luke 1412 they may invite you back power point church sermon
0514 luke 1412 they may invite you back power point church sermon
 
Generation Myth
Generation MythGeneration Myth
Generation Myth
 
Majournee ainoa
Majournee ainoaMajournee ainoa
Majournee ainoa
 
Joe Vitale - Lesson4
Joe Vitale - Lesson4Joe Vitale - Lesson4
Joe Vitale - Lesson4
 
Conecta 4
Conecta 4Conecta 4
Conecta 4
 
Preguntas cuadradas
Preguntas cuadradasPreguntas cuadradas
Preguntas cuadradas
 
Stereotip & Halo
Stereotip & Halo Stereotip & Halo
Stereotip & Halo
 

Recently uploaded

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 

Recently uploaded (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Using StateCharts on small electronic devices; for fun, profit and numbats

  • 1. Using StateCharts on small electronic devices; for fun, profit and numbats Harry McNally, Decisions and Designs, BarCamp Perth 2009
  • 2. Harry McNally, Decisions and Designs, 2009
  • 3. Images: Department of Premier and Cabinet Harry McNally, Decisions and Designs, 2009
  • 4. International Union for Conservation of Nature and Natural Resources (IUCN) Red List of Threatened Species In 2008 Photo by Gnangarra ... commons.wikimedia.org Conservation Status Graphics by Peter Halasz Photo by Aaron Siirila Harry McNally, Decisions and Designs, 2009
  • 5. Harry McNally, Decisions and Designs, 2009
  • 6. http://www.numbat.org.au/ Harry McNally, Decisions and Designs, 2009
  • 7. Harry McNally, Decisions and Designs, 2009
  • 8. Harry McNally, Decisions and Designs, 2009
  • 9. Harry McNally, Decisions and Designs, 2009
  • 10. Harry McNally, Decisions and Designs, 2009
  • 11. Harry McNally, Decisions and Designs, 2009
  • 12. Storyboard Panel 1. Setup the camera and to standby Tony arrives at an observation site at early twilight and positions the video camera at the hollow log. He turns the camera on and checks that it is viewing correctly. He sets the camera to standby. Harry McNally, Decisions and Designs, 2009
  • 13. Storyboard Panel 2. Adjust the clock time if required Tony checks the clock time on numbatcam and, if it needs adjustment, he presses and holds the Select button and uses Up and Down buttons to adjust the clock time minute by minute. If he holds the Up or Down button for a second the time increments automatically; slowly at first and quickly after 6 seconds to allow simple hours adjustment. Tony releases the Select button once the clock time is correctly set and the start time displays. If the clock time did not need adjustment, Tony simply presses and releases the Select button to display the start time. Harry McNally, Decisions and Designs, 2009
  • 14. Storyboard Panel 3. Adjust the start time if required Tony checks the start time on numbatcam and, if it needs adjustment, he presses the Up and Down buttons to adjust the clock time minute by minute. If he holds the Up or Down button for one second the time changes automatically; slowly at first and quickly after 6 seconds to allow simple hours adjustment. Once the start time is correct Tony presses and releases the Select button to return to the clock time. The starter is now armed and this is shown by a flashing asterisk instead of a flashing cursor. Harry McNally, Decisions and Designs, 2009
  • 15. Storyboard Panel 4. Test the camera start/stop manually Tony presses the numbatcam Manual button to send a Start/Stop (IR remote) message to the camera. He checks that the camera has started and presses the Manual button again to return the camera to standby. Harry McNally, Decisions and Designs, 2009
  • 16. Storyboard Panel 5. Numbats! Tony returns the next morning and stops and retrieves the camera for viewing and analysis. Harry McNally, Decisions and Designs, 2009
  • 17. Harry McNally, Decisions and Designs, 2009
  • 18. Existing hardware ? AVR Butterfly http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3146 Harry McNally, Decisions and Designs, 2009
  • 19. Small efficient state code ? http://www.state-machine.com/ http://www.state-machine.com/psicc2/index.htm#Errata http://www.state-machine.com/avr/QDKn_AVR-GNU.pdf Harry McNally, Decisions and Designs, 2009
  • 20. Button Driver Event Event Event queue queue queue IR Alarm Transmit Clock UI Task Task Task Harry McNally, Decisions and Designs, 2009
  • 21. Harry McNally, Decisions and Designs, 2009
  • 22. static QState UI_displayTime(UI *me) { switch (Q_SIG(me)) { case Q_ENTRY_SIG : { QActive_post((QActive *)&AO_alarmClock, DISPLAY_TIME_SIG); return Q_HANDLED(); } case SELECT_BUTTON_PRESS_SIG : { return Q_TRAN(&UI_setTime); } case MANUAL_BUTTON_PRESS_SIG : { QActive_post((QActive *)&AO_IR, IR_TRANSMIT_SIG); return Q_HANDLED(); } } return Q_SUPER(&QHsm_top); } Harry McNally, Decisions and Designs, 2009
  • 23. static Qstate UI_setTime(UI *me) { switch (Q_SIG(me)) { case UP_BUTTON_PRESS_SIG : { return Q_TRAN(&UI_incrementTime); } case DOWN_BUTTON_PRESS_SIG : { return Q_TRAN(&UI_decrementTime); } case SELECT_BUTTON_RELEASE_SIG : { return Q_TRAN(&UI_setAlarm); } case UP_BUTTON_RELEASE_SIG : { return Q_TRAN(&UI_setTime); } case DOWN_BUTTON_RELEASE_SIG : { return Q_TRAN(&UI_setTime); } } return Q_SUPER(&UI_displayTime); } Harry McNally, Decisions and Designs, 2009
  • 24. static QState UI_incrementTime(UI *me) { switch (Q_SIG(me)) { case Q_ENTRY_SIG : { QActive_post((QActive *)&AO_alarmClock, INCREMENT_SIG); QActive_arm((QActive *)me, SET_HOLD); return Q_HANDLED(); } case Q_EXIT_SIG : { QActive_disarm((QActive *)me); return Q_HANDLED(); } case Q_TIMEOUT_SIG : { return Q_TRAN(&UI_autoIncrementTimeSlow); } } return Q_SUPER(&UI_setTime); } Harry McNally, Decisions and Designs, 2009
  • 25. static QState UI_autoIncrementTimeSlow(UI *me) { switch (Q_SIG(me)) { case Q_ENTRY_SIG : { QActive_post((QActive *)&AO_alarmClock, INCREMENT_SIG); QActive_arm((QActive *)me, SET_SLOW_REPEAT); me->repeatCount = 0; return Q_HANDLED(); } case Q_TIMEOUT_SIG : { QActive_post((QActive *)&AO_alarmClock, INCREMENT_SIG); QActive_arm((QActive *)me, SET_SLOW_REPEAT); me->repeatCount++; if (me->repeatCount >= SLOW_REPEAT_COUNT) { return Q_TRAN(&UI_autoIncrementTimeFast); } return Q_HANDLED(); } } return Q_SUPER(&UI_incrementTime); } Harry McNally, Decisions and Designs, 2009
  • 26. static QState UI_autoIncrementTimeFast(UI *me) { switch (Q_SIG(me)) { case Q_ENTRY_SIG : { QActive_post((QActive *)&AO_alarmClock, INCREMENT_SIG); QActive_arm((QActive *)me, SET_FAST_REPEAT); return Q_HANDLED(); } case Q_TIMEOUT_SIG : { QActive_post((QActive *)&AO_alarmClock, INCREMENT_SIG); QActive_arm((QActive *)me, SET_FAST_REPEAT); return Q_HANDLED(); } } return Q_SUPER(&UI_incrementTime); } Harry McNally, Decisions and Designs, 2009
  • 27. From the AVR Studio build: ---------------- Device: atmega169p Program: 5192 bytes (31.7% Full) (.text + .data + .bootloader) Data: 51 bytes (5.0% Full) (.data + .bss + .noinit) Harry McNally, Decisions and Designs, 2009
  • 28. Questions ? Harry McNally, Decisions and Designs, 2009
  • 29. http://www.numbat.org.au/ http://www.state-machine.com/ http://www.state-machine.com/psicc2/index.htm#Errata http://www.state-machine.com/avr/QDKn_AVR-GNU.pdf AVR Butterfly http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3146 Harry McNally, Decisions and Designs, 2009