This clock is based on Led Clock by David Horn posted on here some time ago. The principle of the clock is minimalism. The left column represents the hous, the next five columns represent minutes and the final column represents groups of five seconds (if you choose the 'show seconds' option). The hours increment upwards, the minutes increment leftwards then upwards and the seconds increment upwards. I have taken David’s original clock idea and bolted on lots of user options purely as an exercise to get up to speed programming for the compact framework.
Features
=======
Set individual colours for many elements such as hour leds, minute leds, second leds, frame, font and background.
Draw rectangular or round leds
Show / Hide seconds
Show digits on hours, minutes, seconds
Change led size – small, medium, large.
Imaging:
Load image as foreground, the image gets drawn piece by piece like a jigsaw as another led gets added to the clock. Watch your image build up on screen as the hour goes by. Alternatively you can set the image as a background image and the clock gets drawn on top.
Image Folders:
You can also specify a folder of images and set the rotation frequency to minute, hour or day. The current image behaves as above and gets rotated so you can have a new image loaded every day, or hour etc.
I am using GDI to draw the clock but it is heavily optimized. The thread only runs every 5 secs or every 60 secs if you choose not to show seconds. The drawing itself only draws what is absolutely necessary at any time. So if we are not refreshing / painting the form, usually we are only drawing a single led therefore this should be light on resources. As evidence of this, consider the fact that I am not using double buffering anywhere and yet the redrawing is always flicker free and stable.
I wrote this clock as a Touch HD owner but tested it on several of the mobile images. It should run on any Windows Mobile device and on most screen resolutions from version 5 upwards. It currently uses .Net 3.5 but I can port it back to 2.0 if required as all the code is legacy written and I am using no libraries from the newer framework. I’d appreciate any reasonable feedback.
Previews
======
Surely this should've been posted in the themes, apps and software section?
MOD EDIT
Moved to themes, apps and software forum
oops, sorry about that.
Hello gents.
I have an application under development and I need to rotate an image for an angle of -40 to 40 dgs. I found something on the web,but it is too difficult at this time for me...
http://www.codeguru.com/cpp/g-m/bitmap/imagemanipulation/article.php/c10677/
All I need is a rotated bitmap with dimensions of 250x250pix,same as source.
I don't need the corners,because it is actually rounded bitmap with black corners.
All I need is a void function,which rotates source bitmap to destination one.
I attached also my image,which I want to rotate.
Can anybody help me with this please?
The easiest, simplest and fastest method is to use a drawing program on the PC to create a series of bitmap images already rotated to the desired angle.
Do you really need all 81 images, 1 degree apart, or will a 5 degree increment suffice? Your call, the fewer the simpler.
Store the images in the resource file and draw them to the screen when required.
In this case IDB_BITMAP1 will be the resource ID of the image you require.
If you arrange for all the resource ID's to be consecutive values they can be selected using (IDB_BASE + offset_integer_variable)
To draw it at position x,y
Code:
HBITMAP hbitmap;
hdc=GetDC(hWnd);
hdcMem=CreateCompatibleDC(hdc);
hbitmap=LoadBitmap(hInstance,MAKEINTRESOURCE(IDB_BITMAP1));
SelectObject(hdcMem,hbitmap);
BitBlt(hdc,x,y,250,250,hdcMem,0,0,SRCCOPY);
DeleteDC(hdcMem);
ReleaseDC(hWnd,hdc);
To rotate the image by code can be done, but as you say the code gets pretty complicated and also has a hit on program performance.
Sometimes less is more.
Just a bit late,but after all.
This method I am using normally,but it limits my needs.
The resource image I do need 250x250 pix, X162 in my app)2 rotating images) that means image with dimensions of 2500x4250,that is too much even for Snapdragons and it simply doesn't load that. Therefore I was forced to reduce base resolution to 125x125,but some people reports also problems.
Check out this thread:
http://forum.xda-developers.com/showthread.php?t=682330
Another approach, but it still needs a bit of work and won't look quite as good, (although the more work you put into it, the better it will look), is to draw the image using the GDI drawing functions, in effect turning it into a vector image. Each change in angle would clear the area, then redraw the image. It does not need any memory or resources, merely CPU power to draw it, but GDI drawing is extremely fast.
Another advantage of this method is that it can be scaled to any image size.
The start/end points of lines, central points of circles etc. of each shape can then be rotated round the centre of the image by the angle required, using:
x'= x*Cos(θ)-y*Sin(θ)
y'= x*Sin(θ)+y*Cos(θ)
Where x and y are the distances relative to the centre of the image. Remember that θ is in radians.
In a normal x,y coordinate system (x,y math function graphs etc.) positive values of θ will result in an anticlockwise rotation. In the screen coordinate system 0,0 is the top left of the screen not the bottom left. Y coordinates are in effect inverted, so positive values of θ will result in a clockwise rotation.
You won't be able to use rectangles, as RECT structures and methods that operate on them, only work with horizontally and vertically aligned blocks. You would have to use polygons instead. If you are calculating the next position based on the previous position, as shown in the code below, the values must be held as double, and converted to integer points before drawing them, or the progressive rounding down, will result in the image being drawn progressively smaller. An interesting effect, but not quite what you really want.
To prove this works have a look at the attached, an example of rotating a square.....
Code:
double ptsx[4],ptsy[4];
double st,ct;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
ptsx[0]=ptsy[0]=ptsy[1]=ptsx[3]=50;
ptsx[1]=ptsx[2]=ptsy[2]=ptsy[3]=-50;
st=sin(0.1);
ct=cos(0.1);
GetWindowRect(hWnd, &rt);
GetWindowRect(g_hWndMenuBar,&rtMenu);
mx=(rt.right-rt.left)/2;
my=(rtMenu.top-rt.top)/2;
SelectObject(hdc,GetStockObject(BLACK_PEN));
for(j=0;j<4;j++)
{
MoveToEx(hdc,mx+(int)ptsx[0],my+(int)ptsy[0],NULL);
LineTo(hdc,mx+(int)ptsx[1],my+(int)ptsy[1]);
LineTo(hdc,mx+(int)ptsx[2],my+(int)ptsy[2]);
LineTo(hdc,mx+(int)ptsx[3],my+(int)ptsy[3]);
LineTo(hdc,mx+(int)ptsx[0],my+(int)ptsy[0]);
for(i=0;i<4;i++)
{
x=ptsx[i]*ct - ptsy[i]*st;
y=ptsx[i]*st + ptsy[i]*ct;
ptsx[i]=x;
ptsy[i]=y;
}
}
EndPaint(hWnd, &ps);
break;
I want to use the numerical values of #BLEV# (battery level) and #WCHUM# (weather, current humidity) in calculations. In the first case to change the dimension of a rectangle, in the second case to calculate the rotation of a pointer in an analog gauge.
Both values are supplied by ZW as percentiles, complete with the "%" character which renders them unusable in a calculation. I have tried using $(#BLEV#)$ and $(#WCHUM#)$ - which works to remove the units in #WCTEMP# and #WCPRESS# - but it won't work in these two cases.
Is there a solution?
TIA
Terry
gritpipethin said:
I want to use the numerical values of #BLEV# (battery level) and #WCHUM# (weather, current humidity) in calculations. In the first case to change the dimension of a rectangle, in the second case to calculate the rotation of a pointer in an analog gauge.
Both values are supplied by ZW as percentiles, complete with the "%" character which renders them unusable in a calculation. I have tried using $(#BLEV#)$ and $(#WCHUM#)$ - which works to remove the units in #WCTEMP# and #WCPRESS# - but it won't work in these two cases.
Is there a solution?
TIA
Terry
Click to expand...
Click to collapse
Try using #BLEVN# and #WCHUMN#. I know the batt Lev one works, so I'm assuming that just adding 'N' at the end of a variable will output the numerical value only.
Hope this helps.
Cheers.
Majik Mushroomz said:
Try using #BLEVN# and #WCHUMN#. I know the batt Lev one works, so I'm assuming that just adding 'N' at the end of a variable will output the numerical value only.
Hope this helps.
Cheers.
Click to expand...
Click to collapse
#BLEVN# works beautifully (and I should have found that myself), but #WCHUMN# is not, as they say, a happening thing.
Thanks.
I would like to request the ability to apply a locality to a rectangle.
I want to design a widget that is a dual-time-zone analog clock. One hour hand would be for local time, and a second hour hand would be for a specified location. Because hour hands are implemented using rectangles and Advanced Parameters that specify sweep angle and rotation as a function of time, I need to be able to specify the locality of the rectangle separately from the widget so that the Advanced Parameters will use the correct time--that of the rectangle, not of the widget.
If this is not the correct forum for feature requests, please let me know where that is.
Thanks.
Jeff Jansen
jsjansen said:
I would like to request the ability to apply a locality to a rectangle.
I want to design a widget that is a dual-time-zone analog clock. One hour hand would be for local time, and a second hour hand would be for a specified location. Because hour hands are implemented using rectangles and Advanced Parameters that specify sweep angle and rotation as a function of time, I need to be able to specify the locality of the rectangle separately from the widget so that the Advanced Parameters will use the correct time--that of the rectangle, not of the widget.
If this is not the correct forum for feature requests, please let me know where that is.
Thanks.
Jeff Jansen
Click to expand...
Click to collapse
Might I suggest that you use the timezone in the sweep angle/ rotation calculation. If you use local time + timezone offset that should adjust the rectangle correctly. I did something like this to make a clock like xkcd:Now (google, I can't post outside links yet ). The outer edge is fixed and the colored timezones rotate. I tried to incorporate the #DZ# variable but I haven't got this quite working yet.
I am trying to create an old school weather center with temperature, Humidity, and Pressure. I can make hands using a progress bar by setting the main and secondary colors clear and setting the gradent to highlight current. I dont like the reverse wedge shape though. What I need are the conditionals for using a rectangle as hands. I need the complete conditionals for a 360 degree sweep for each one, and what to change for different sweeps. Example: I want my humidity to sweep 300 degrees, starting at - 30 degrees. Also. I hear of a way to make bitmap images sweep with progress bar. This may help more as i can use fancy instrument needles for indicators.
Wrong thread