gonium.net » code http://gonium.net/md so much time, so little to do. Sat, 11 Sep 2010 16:42:09 +0000 en hourly 1 http://wordpress.org/?v=3.0.1 Leopard+Terminal+Spaces workaround http://gonium.net/md/2007/11/26/leopardterminalspaces-workaround/ http://gonium.net/md/2007/11/26/leopardterminalspaces-workaround/#comments Mon, 26 Nov 2007 13:25:45 +0000 md http://gonium.net/md/2007/11/26/leopardterminalspaces-workaround/ leopard

Overall, I like the new Apple MacOS 10.5 aka Leopard. I used various virtual desktop solutions with older versions, but the new Spaces provides everything I need – almost. On a typical workday, I have various terminal windows opened – but not on one workspace! Spaces changes the screen to one that has a terminal currently running, which is a stupid behavior. There is also no way to change this. But a workaround…

If you have a terminal on space one and you’re on space three, clicking the terminal icon moves you to terminal one. What I would like to have is a new terminal on space three. You can do this with the following (trivial) applescript:


tell application "Terminal"
do script ""
end tell

So, basically the Terminal is asked to execute an empty script – which results in a new window without changing the current desktop.

Either you use the script editor to build your own applescript implementation, or you download a precompiled version below. I dropped the script into the dock for easy access. Now I have only two remaining questions:

  1. How can I change the icon of the applescript?
  2. How can I assign a keyboard shortcut to it?

Hopefully, Spaces allows you to deactivate the switching behavior in future revisions.

The leopard pic was released under a CC-Attribution-No Derivative Works license by Matt McGee.

]]>
http://gonium.net/md/2007/11/26/leopardterminalspaces-workaround/feed/ 1
Tweaking the code http://gonium.net/md/2007/04/18/tweaking-the-code/ http://gonium.net/md/2007/04/18/tweaking-the-code/#comments Wed, 18 Apr 2007 14:54:47 +0000 md http://gonium.net/md/2007/04/18/tweaking-the-code/

Thanks to Lasse Lambrecht, I can release a new version of the DCF77 code – now you can run it on the ATMega168-based Arduinos.

The ATMega8 differs slightly from the ATMega48/88/168-series: The latter chips have an extended Timer2-hardware and therefore need different initializations. Lasse send me a nice adjustment of the code, basically he uses preprocessor flags to figure out which initialization commands to use: #ifdef ATMEGA168 TCCR2B |= (1<
  • arduino-dcf77-clock-0.2.1.tar.bz
  • For the hardware setup, please refer to my initial post. ]]>
    http://gonium.net/md/2007/04/18/tweaking-the-code/feed/ 12
    I will think before I code… http://gonium.net/md/2006/12/27/i-will-think-before-i-code/ http://gonium.net/md/2006/12/27/i-will-think-before-i-code/#comments Wed, 27 Dec 2006 09:54:04 +0000 md http://gonium.net/md/2006/12/27/i-will-think-before-i-code/ #include < avr / io.h > #define INIT_TIMER_COUNT 6 #define RESET_TIMER2 TCNT2 = INIT_TIMER_COUNT int ledPin = 13; [...]]]> CosineKitty pointed out: My Arduino timer interrupt code did not work because the Prescaler bits were not set correctly. Applying basic boolean logic helps ;-) This is the working code: #include < avr / interrupt.h > #include < avr / io.h > #define INIT_TIMER_COUNT 6 #define RESET_TIMER2 TCNT2 = INIT_TIMER_COUNT int ledPin = 13; int int_counter = 0; volatile int second = 0; int oldSecond = 0; long starttime = 0; // Aruino runs at 16 Mhz, so we have 1000 Overflows per second... // 1/ ((16000000 / 64) / 256) = 1 / 1000 ISR(TIMER2_OVF_vect) { RESET_TIMER2; int_counter += 1; if (int_counter == 1000) { second+=1; int_counter = 0; } }; void setup() { Serial.begin(9600); Serial.println("Initializing timerinterrupt"); //Timer2 Settings: Timer Prescaler /64, TCCR2 |= (1< "); Serial.print(millis() - starttime); Serial.println("."); digitalWrite(ledPin, HIGH); delay(100); digitalWrite(ledPin, LOW); oldSecond = second; } } I will think before I code, I will think before I code, I will think before I code, ... The timer now works perfectly. I think the CTC mode will be more efficient, but my measurement shows that the clock has a slight skew (3 ms) when the Arduino starts up (lets say, during the first five minutes). Later, the skew is about zero. So the overflow mechanism is quite exact ;-) Note that the TIMER2 is used for PWM in the Arduino libraries, so this sketch might interfere with PWM applications - I did not test this.]]> http://gonium.net/md/2006/12/27/i-will-think-before-i-code/feed/ 24 Arduino Timer Interrupt http://gonium.net/md/2006/12/23/arduino-timer-interrupt/ http://gonium.net/md/2006/12/23/arduino-timer-interrupt/#comments Sat, 23 Dec 2006 22:12:02 +0000 md http://gonium.net/md/2006/12/23/arduino-timer-interrupt/ Continuing my interrupt experiments, I wrote a little sketch to print the seconds since startup to serial. But: Something is wrong…

    I use the Timer2 of the ATMega8. It consists of a 8 bit counter which is automatically increased. When an overflow occurs, the interrupt routine TIMER2_OVF_vect is called.

    This is the code:

    
    #include < avr / interrupt.h >
    #include < avr / io.h >
    
    #define INIT_TIMER_COUNT 0
    #define RESET_TIMER2 TCNT2 = INIT_TIMER_COUNT
    
    int ledPin = 13;
    int int_counter = 0;
    volatile int second = 0;
    int oldSecond = 0;
    
    // Aruino runs at 16 Mhz, so we have 61 Overflows per second...
    // 1/ ((16000000 / 1024) / 256) = 1 / 61
    ISR(TIMER2_OVF_vect) {
      int_counter += 1;
      if (int_counter == 61) {
        second+=1;
        int_counter = 0;
      }
    };
    
    void setup() {
      Serial.begin(9600);
      Serial.println("Initializing timerinterrupt");
      //Timer2 Settings:  Timer Prescaler /1024
      TCCR2 |= ((1 < < CS22) | (1 << CS21) | (1 << CS20));
      //Timer2 Overflow Interrupt Enable
      TIMSK |= (1 << TOIE2);
      RESET_TIMER2;
      sei();
    }
    
    void loop() {
      if (oldSecond != second) {
        Serial.print(second);
        Serial.println(".");
        oldSecond = second;
      }
    }
    
    

    Unfortunately, the counter is not increased every second but every three seconds. I need to investigate this. Anyway, it seems to be more reasonable to use the CTC mode (clear-timer-on-compare-match). I need to read the datasheet ;-)

    ]]>
    http://gonium.net/md/2006/12/23/arduino-timer-interrupt/feed/ 0