Monday, 15 November 2010

Adding custom notifications to the WM6.5 lock screen

If you are wondering how your application can add information on the new WM6.5 lock screen, this can be done easily by utilising a few registry entries! There are two OEM lockscreen entries reserved for OEM applications that will allow applications to register an icon to show on the lock screen with an optional number of unread or unhandled events, when the user slides this to the right or left the application is invoked to deal with the unread events.

The regsitry entry all of this appears under is:

HKLM\Software\\Microsoft\\Shell\\LockScreen\\Notifications\\Notif0
HKLM\Software\\Microsoft\\Shell\\LockScreen\\Notifications\\Notif1

Add the settings like this:

"Command Line"="\program files\myapp\myapp.exe"
"Image"="\icon_notclicked.png"
"FocusImage"="\icon_clicked.png"
"Notification Count"=dword:0

The command line should point to your application, this will be executed when the user slides your cusom slider to the right. The Image and Focus image are two icons which are shown on the lock screen with and without you pressing them. The notification count should be more than 0 to show your icon and 0 to hide your item. The number in the noticication count is displayed on the lock screen so this could be the number of unread messages or emails you've received, whatever you are counting in your application.

You should check that Notif0 and 1 aren't already used by another application and use the appropriate one.

Happy screen locking!

Wednesday, 27 October 2010

Accessing the phone vibrator

How can I access the vibrate function from my apps you may say...?

Well the vibrate function is part of the NLED (or notification LED) driver. You can use the NLED functions to pulse or turn on/off the motor in the same way as any LED. To find the vibrator search through the list of LEDs until you find one with a cycle time of -1, this indicates the vibrator.

The following code is complete example of searching through the available LEDs and turning on and off only the vibrate function. This should work on any Windows Mobile or Windows CE with a compatible NLED driver:


#include "nled.h"

enum Status
{
OFF = 0,
ON,
BLINK
};

int GetLedCount()
{
int count = 0;
NLED_COUNT_INFO nci;
if (NLedGetDeviceInfo(NLED_COUNT_INFO_ID, &nci))
{
count = nci.cLeds;
}
return count;
}

int ledCount = GetLedCount();

void SetLedStatus(Status status)
{
NLED_SETTINGS_INFO nsi;
NLED_SUPPORTS_INFO nInfo;
nsi.OffOnBlink = (uint)status;
for (int i = 0; i < ledCount; i++)
{
// request information from this led, we're looking for a
// cycleAdjust of -1 which indicates the vibrator
nInfo.LedNum = i;
NLedGetDeviceInfo(NLED_SUPPORTS_INFO_ID, &nInfo);
if (nInfo.lCycleAdjust == -1)
{
nsi.LedNum = (uint)i;
NLedSetDevice(NLED_SETTINGS_INFO_ID, &nsi);
}
}
}

void VibrateOn()
{
SetLedStatus(Status::ON);
}

void VibrateOff()
{
SetLedStatus(Status::OFF);
}


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow)
{
VibrateOn();
Sleep(500);
VibrateOff();
}

Tuesday, 12 October 2010

Missing Ordinals in Windows CE

If you get the message:

ERROR: function @ Ordinal 297 missing
Please Check your SYSGEN variable!!!


Then the problem is most likely to be a missing funciton in CoreDLL, to check which it is go to the private sources:

\WINCE600\PRIVATE\WINCEOS\COREOS\CORE\DLL>notepad core_common.def

In this you should be able to search for the ordinal number

; @CESYSGEN IF COREDLL_BATTERY
BatteryDrvrGetLevels=BatteryDrvrGetLevels @297
BatteryDrvrSupportsChangeNotification=BatteryDrvrSupportsChangeNotification @298
BatteryGetLifeTimeInfo=BatteryGetLifeTimeInfo @713
BatteryNotifyOfTimeChange=BatteryNotifyOfTimeChange @714
GetSystemPowerStatusEx=GetSystemPowerStatusEx @715
GetSystemPowerStatusEx2=GetSystemPowerStatusEx2 @1358
; @CESYSGEN ENDIF

Wednesday, 29 September 2010

Using events and waking devices using CeRunAppAtTime

Want to wake up a CE device at a future time (even if it is suspend), then use the CeRunAppAtTime but instead of running an app use a named event, this allows an application to wake up the device at a set time and also trap the wake event without spawning another process:

SYSTEMTIME time;
CTime nextWakeUpTime;

// get local system time and convert time to CTime for now
GetLocalTime(&time);
CTime now(time);

// 30 minutes in the future
nextWakeUpTime=now;
nextWakeUpTime+=CTimeSpan(0,0,30,0);

// convert to systemtime
nextWakeUpTime.GetAsSystemTime(time);

// set for wake up !
CeRunAppAtTime(TEXT("\\\\.\\Notifications\\NamedEvents\\SCHEDULE_WAKEEVENT_EVENT"), &time);

HANDLE wakeEvent = CreateEvent(NULL, FALSE, FALSE, SCHEDULE_WAKEEVENT_EVENT);

// wait for wake up!
if (WaitForSingleObject(wakeEvent, FALSE, INFINITE) == WAIT_OBJECT_0)
{
// sheduled wake up
}

Friday, 10 September 2010

KITL Messages Don't Support Wide Strings

I've just tracked down a minor irritation with KITL_RETAILMSG and KITL_DEBUGMSG under CE 6.0 R3 - they can't print UNICODE or wide strings.

On several platforms I've seen the KITL device name is not printed correctly. The device name is the name member of the OAL_KITL_DEVICE structure and is defined as a LPCWSTR.

Typically OALKitlInit uses KITL_RETAILMSG to report the device name but the name is never displayed correctly. The string is formatted as "%s" but only the first letter is shown - this implies that the wide string is being formatted as a character string. Trying %hs or %S to override the default does not help.

Reviewing the private sources confirms the problem. Only the %s format is supported and this is for character strings only.

Also be aware that formatting such as %08x is not supported either, but %X is fine!

Monday, 6 September 2010

Using #include from BIB files



Did you know that inside of Windows CE build system that bib files can #include other bib files. This technique is used on many BSP's to implement individual driver registry entries from the driver directory

platform.reg
#include "$(_TARGETPLATROOT)\SRC\DRIVERS\display\display.reg"

The same can be done for the bib file, I didn't release this before, but its there to use if you want to in CE6.0 for sure!

platform.bib
#include "$(_TARGETPLATROOT)\SRC\DRIVERS\display\display.bib"

Wednesday, 18 August 2010

Page faults on resume from suspend with COMPRESSION=on

A short while ago we had a problem on a platform resuming from suspend, a page fault calling a standard function. The function in question was a Registry query function. The fault was tracked down to that fact that when the config.bib specifies compression like:
COMPRESSION=ON
This means that all files are put into the nk.bin image back to back without any space between them, even running the image from RAM most of these files cannot be executed in place as the file aren't aligned on a page boundary, these files need to be copied into ram on a boundary and executed.
In the project above we needed to use the API so a solution was to turn off the COMPRESSION, this increases the NK.BIN size but helps in lower RAM usage and faster response times due to no duplication of files into executable positions.