Category: Projects Related to Palm OS PDAs

Automatically Turn On the Backlight

Published on: 2021-02-13

This is a very small application and it already exists, but the one I found (https://www.whizoo.com/apps/backlight.php) didn't work for me, so I wrote my own version.

The problem is simple: If you have a Sony Clie S3x0 or a SL10, you know that the screen is very hard to read in low-light conditions. Of course, you can manually turn on the backlight, but you need to do it very often. So why not automate this step and turn it on every time the screen is activated? With this application installed, the backlight is on by default (it gets turned on every time the device is turned on). The app works only on black-and-white devices with backlight. So far, it has been tested successfully on a Sony Clié S320.

Requirements: Palm OS 4.0 (or higher)

Here is the application:

EverBacklight.prc

If you want to use this application, it is important that you install it via a hotsync or do a soft-reset after copying it to your device. And here is the source code:

/*
 * EverBacklight.cpp
 *
 * Main file for EverBacklight
 *
 */
 
#include <PalmOS.h>
#include <PalmOSGlue.h>

#include "EverBacklight.h"
#include "EverBacklight_Rsc.h"

/* Define the minimum OS version we support */
#define ourMinVersion    sysMakeROMVersion(4,0,0,sysROMStageDevelopment,0)

static void RegisterForNotifications()
{
    UInt16 cardNo = 0;
    UInt32 romVersion = 0;
    LocalID dbID = 0;

    FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
    if (romVersion < ourMinVersion) {
        return;
    }
  
    if (SysCurAppDatabase(&cardNo, &dbID) != 0) {
        return;
    }
   
    SysNotifyRegister(cardNo, dbID, sysNotifyLateWakeupEvent, NULL, sysNotifyNormalPriority, 0);
}

static void HandleNotifications(SysNotifyParamType *np)
{
    if (np->notifyType == sysNotifyLateWakeupEvent) {
        UIBrightnessAdjust(); // Toggle Backlight
    }
}

UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
    switch (cmd) {    
        case sysAppLaunchCmdSystemReset: 
        case sysAppLaunchCmdSyncNotify:
            RegisterForNotifications();
            break;

        case sysAppLaunchCmdNotify:
            HandleNotifications((SysNotifyParamType *)cmdPBP);
            break;
    }

    return errNone;
}