Android Question Rotating Disk Meter

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,

I'm working on a project that will mimic an instrument's meter. Part of the meter is a rotating disc that measures tenths of a unit – as it rotates past 9/10 and back around to 0, it increments the units dial by one and continues rotating measuring tenths.

Below is an image that shows an electrical power meter that's common in the USA. The red arrow points to the power meter tenths gauge. This is a disc that continually rotates clockwise measuring tenths of a kilowatt hour of power usage.

upload_2014-9-12_20-25-27.png


I need to implement a similar gauge. My gauge has the markings on the disc's edge rather than the top face – to be viewed from the side rather than from the top.

It would be easy to do it with a digital counter, but it would be nicer to have the display eye candy making it look like the current instrument.

I'm wondering how I might implement something like this. My initial thoughts are to use a panel with a horizontal scrollview. The numbers, 0 - 9, scroll across the panel from the right to left. Following the number 9 it starts over again with 0. A complication is that it can also scroll backwards.

Can anybody suggest how I might approach this? Is something similar to this already available? As I think about it, a horizontal scrollview is probably not the way to go.

Thanks,
Barry.
 

LucaMs

Expert
Licensed User
Longtime User
If I wanted to implement the underlying disk (in the figure) and see it from the front, I would draw the disc (before I would search it on Internet :D) and would "draw" using the function DrawBitmapRotated of Canvas, by varying the angle.
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
That's definitely a possibility and that would preserve the 3D-ness of the meter.

Unfortunately, I can't take a picture of the actual meter that I'm trying to simulate. My description probably wasn't very good. The actual meter is a horizontal rectangle with a row of numbers that seem to slide back and forth as the value they are indicating changes (the sliding numbers are actually on a rotating disc). The value is specified by a vertical line etched in a glass globe covering the meter.

One way I thought of is to keep an internal canvas bitmap with the numbers 0 - 9 written on it a couple times. I would copy a subset of this canvas, with my desired indicated value located at the center, to the visible meter control. The control will appear animated depending on how fast I can copy the canvas subset to it. The image below shows 4 snapshots of the control indicating different values – you have to imagine that it's animated.

upload_2014-9-13_0-14-47.png


I think this might possibly work.

I may also be able to use a bitmap from the web that has a nice 3-D effect.

Barry.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Are you looking for something like this ?

upload_2014-9-13_20-28-14.png


Attached the project, it's a CustomView Class.
It can be added in the code or in the Designer.
It's based on a HorizontalScrollView.
The class can also be compiled as a Library.
 

Attachments

  • RotatingMeter.zip
    9.4 KB · Views: 232
Last edited:
Upvote 0
Top